(node_factory, bitcoind)
| 3142 | |
| 3143 | |
| 3144 | def test_permfail(node_factory, bitcoind): |
| 3145 | l1, l2 = node_factory.line_graph(2) |
| 3146 | |
| 3147 | # The funding change should be confirmed and our only output |
| 3148 | assert [o['status'] for o in l1.rpc.listfunds()['outputs']] == ['confirmed'] |
| 3149 | l1.pay(l2, 200000000) |
| 3150 | |
| 3151 | # Make sure l2 has received sig with 0 htlcs! |
| 3152 | l2.daemon.wait_for_log('Received commit_sig with 1 htlc sigs') |
| 3153 | l2.daemon.wait_for_log('Received commit_sig with 0 htlc sigs') |
| 3154 | |
| 3155 | # Make sure l1 has final revocation. |
| 3156 | l1.daemon.wait_for_log('Sending commit_sig with 1 htlc sigs') |
| 3157 | l1.daemon.wait_for_log('Sending commit_sig with 0 htlc sigs') |
| 3158 | l1.daemon.wait_for_log('peer_in WIRE_REVOKE_AND_ACK') |
| 3159 | |
| 3160 | # We fail l2, so l1 will reconnect to it. |
| 3161 | l2.rpc.dev_fail(l1.info['id']) |
| 3162 | l2.daemon.wait_for_log('Failing due to dev-fail command') |
| 3163 | l2.wait_for_channel_onchain(l1.info['id']) |
| 3164 | |
| 3165 | assert l1.bitcoin.rpc.getmempoolinfo()['size'] == 1 |
| 3166 | |
| 3167 | # Now grab the close transaction |
| 3168 | closetxid = only_one(l1.bitcoin.rpc.getrawmempool(False)) |
| 3169 | |
| 3170 | # l2 will send out tx (l1 considers it a transient error) |
| 3171 | bitcoind.generate_block(1) |
| 3172 | |
| 3173 | l1.daemon.wait_for_log('Their unilateral tx, old commit point') |
| 3174 | l1.daemon.wait_for_log(' to ONCHAIN') |
| 3175 | l2.daemon.wait_for_log(' to ONCHAIN') |
| 3176 | _, txid, blocks = l2.wait_for_onchaind_tx('OUR_DELAYED_RETURN_TO_WALLET', |
| 3177 | 'OUR_UNILATERAL/DELAYED_OUTPUT_TO_US') |
| 3178 | assert blocks == 4 |
| 3179 | |
| 3180 | wait_for(lambda: only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['status'] |
| 3181 | == ['ONCHAIN:Tracking their unilateral close', |
| 3182 | 'ONCHAIN:All outputs resolved: waiting 99 more blocks before forgetting channel']) |
| 3183 | |
| 3184 | def check_billboard(): |
| 3185 | billboard = only_one(l2.rpc.listpeerchannels(l1.info['id'])['channels'])['status'] |
| 3186 | return ( |
| 3187 | len(billboard) == 2 |
| 3188 | and billboard[0] == 'ONCHAIN:Tracking our own unilateral close' |
| 3189 | and re.fullmatch(r'ONCHAIN:.* outputs unresolved: in 4 blocks will spend DELAYED_OUTPUT_TO_US \(.*:.*\) using OUR_DELAYED_RETURN_TO_WALLET', billboard[1]) |
| 3190 | ) |
| 3191 | wait_for(check_billboard) |
| 3192 | |
| 3193 | # Now, mine 4 blocks so it sends out the spending tx. |
| 3194 | bitcoind.generate_block(4) |
| 3195 | |
| 3196 | # onchaind notes to-local payment immediately. |
| 3197 | assert (closetxid, "confirmed") in set([(o['txid'], o['status']) for o in l1.rpc.listfunds()['outputs']]) |
| 3198 | |
| 3199 | # Restart, should still be confirmed (fails: unwinding blocks erases |
| 3200 | # the confirmation, and we don't re-make it). |
| 3201 | l1.restart() |
nothing calls this directly
no test coverage detected