(node_factory, bitcoind)
| 3106 | |
| 3107 | @pytest.mark.developer("needs DEVELOPER=1") |
| 3108 | def test_permfail(node_factory, bitcoind): |
| 3109 | l1, l2 = node_factory.line_graph(2) |
| 3110 | |
| 3111 | # The funding change should be confirmed and our only output |
| 3112 | assert [o['status'] for o in l1.rpc.listfunds()['outputs']] == ['confirmed'] |
| 3113 | l1.pay(l2, 200000000) |
| 3114 | |
| 3115 | # Make sure l2 has received sig with 0 htlcs! |
| 3116 | l2.daemon.wait_for_log('Received commit_sig with 1 htlc sigs') |
| 3117 | l2.daemon.wait_for_log('Received commit_sig with 0 htlc sigs') |
| 3118 | |
| 3119 | # Make sure l1 has final revocation. |
| 3120 | l1.daemon.wait_for_log('Sending commit_sig with 1 htlc sigs') |
| 3121 | l1.daemon.wait_for_log('Sending commit_sig with 0 htlc sigs') |
| 3122 | l1.daemon.wait_for_log('peer_in WIRE_REVOKE_AND_ACK') |
| 3123 | |
| 3124 | # We fail l2, so l1 will reconnect to it. |
| 3125 | l2.rpc.dev_fail(l1.info['id']) |
| 3126 | l2.daemon.wait_for_log('Failing due to dev-fail command') |
| 3127 | l2.wait_for_channel_onchain(l1.info['id']) |
| 3128 | |
| 3129 | assert l1.bitcoin.rpc.getmempoolinfo()['size'] == 1 |
| 3130 | |
| 3131 | # Now grab the close transaction |
| 3132 | closetxid = only_one(l1.bitcoin.rpc.getrawmempool(False)) |
| 3133 | |
| 3134 | # l2 will send out tx (l1 considers it a transient error) |
| 3135 | bitcoind.generate_block(1) |
| 3136 | |
| 3137 | l1.daemon.wait_for_log('Their unilateral tx, old commit point') |
| 3138 | l1.daemon.wait_for_log(' to ONCHAIN') |
| 3139 | l2.daemon.wait_for_log(' to ONCHAIN') |
| 3140 | l2.daemon.wait_for_log('Propose handling OUR_UNILATERAL/DELAYED_OUTPUT_TO_US by OUR_DELAYED_RETURN_TO_WALLET (.*) after 5 blocks') |
| 3141 | |
| 3142 | wait_for(lambda: only_one(l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'])['status'] |
| 3143 | == ['ONCHAIN:Tracking their unilateral close', |
| 3144 | 'ONCHAIN:All outputs resolved: waiting 99 more blocks before forgetting channel']) |
| 3145 | |
| 3146 | def check_billboard(): |
| 3147 | billboard = only_one(l2.rpc.listpeers(l1.info['id'])['peers'][0]['channels'])['status'] |
| 3148 | return ( |
| 3149 | len(billboard) == 2 |
| 3150 | and billboard[0] == 'ONCHAIN:Tracking our own unilateral close' |
| 3151 | and re.fullmatch(r'ONCHAIN:.* outputs unresolved: in 4 blocks will spend DELAYED_OUTPUT_TO_US \(.*:.*\) using OUR_DELAYED_RETURN_TO_WALLET', billboard[1]) |
| 3152 | ) |
| 3153 | wait_for(check_billboard) |
| 3154 | |
| 3155 | # Now, mine 4 blocks so it sends out the spending tx. |
| 3156 | bitcoind.generate_block(4) |
| 3157 | |
| 3158 | # onchaind notes to-local payment immediately. |
| 3159 | assert (closetxid, "confirmed") in set([(o['txid'], o['status']) for o in l1.rpc.listfunds()['outputs']]) |
| 3160 | |
| 3161 | # Restart, should still be confirmed (fails: unwinding blocks erases |
| 3162 | # the confirmation, and we don't re-make it). |
| 3163 | l1.restart() |
| 3164 | wait_for(lambda: (closetxid, "confirmed") in set([(o['txid'], o['status']) for o in l1.rpc.listfunds()['outputs']])) |
| 3165 |
nothing calls this directly
no test coverage detected