(node_factory, bitcoind, executor)
| 3439 | |
| 3440 | |
| 3441 | def test_permfail_htlc_in(node_factory, bitcoind, executor): |
| 3442 | # Test case where we fail with unsettled incoming HTLC. |
| 3443 | disconnects = ['-WIRE_UPDATE_FULFILL_HTLC', 'permfail'] |
| 3444 | # Feerates identical so we don't get gratuitous commit to update them |
| 3445 | l1 = node_factory.get_node(options={'dev-no-reconnect': None}, |
| 3446 | feerates=(7500, 7500, 7500, 7500)) |
| 3447 | l2 = node_factory.get_node(disconnect=disconnects) |
| 3448 | |
| 3449 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 3450 | l1.fundchannel(l2, 10**6) |
| 3451 | # Give it some sats for anchor spend! (Extra for elements!) |
| 3452 | l2.fundwallet(30000, mine_block=False) |
| 3453 | |
| 3454 | # This will fail at l2's end. |
| 3455 | t = executor.submit(l1.pay, l2, 200000000) |
| 3456 | |
| 3457 | l2.daemon.wait_for_log('dev_disconnect permfail') |
| 3458 | l2.wait_for_channel_onchain(l1.info['id']) |
| 3459 | bitcoind.generate_block(1) |
| 3460 | l1.daemon.wait_for_log('Their unilateral tx, old commit point') |
| 3461 | l1.daemon.wait_for_log(' to ONCHAIN') |
| 3462 | l2.daemon.wait_for_log(' to ONCHAIN') |
| 3463 | l2.daemon.wait_for_log(r'Propose ignoring OUR_UNILATERAL/THEIR_HTLC as THEIR_HTLC_TIMEOUT_TO_THEM after block [0-9]* \(5 more blocks\)') |
| 3464 | _, _, blocks = l1.wait_for_onchaind_tx('OUR_HTLC_TIMEOUT_TO_US', |
| 3465 | 'THEIR_UNILATERAL/OUR_HTLC') |
| 3466 | assert blocks == 5 |
| 3467 | # l2 then gets preimage, uses it instead of ignoring |
| 3468 | _, txid, blocks = l2.wait_for_onchaind_tx('OUR_HTLC_SUCCESS_TX', |
| 3469 | 'OUR_UNILATERAL/THEIR_HTLC') |
| 3470 | assert blocks == 0 |
| 3471 | bitcoind.generate_block(1, wait_for_mempool=txid) |
| 3472 | |
| 3473 | # OK, l1 sees l2 fulfill htlc. |
| 3474 | l1.daemon.wait_for_log('THEIR_UNILATERAL/OUR_HTLC gave us preimage') |
| 3475 | _, txid, blocks = l2.wait_for_onchaind_tx('OUR_DELAYED_RETURN_TO_WALLET', |
| 3476 | 'OUR_HTLC_SUCCESS_TX/DELAYED_OUTPUT_TO_US') |
| 3477 | assert blocks == 4 |
| 3478 | bitcoind.generate_block(4) |
| 3479 | |
| 3480 | t.cancel() |
| 3481 | |
| 3482 | # Now, 100 blocks it should be done. |
| 3483 | bitcoind.generate_block(95, wait_for_mempool=txid) |
| 3484 | l1.daemon.wait_for_log('onchaind complete, forgetting peer') |
| 3485 | assert not l2.daemon.is_in_log('onchaind complete, forgetting peer') |
| 3486 | bitcoind.generate_block(5) |
| 3487 | l2.daemon.wait_for_log('onchaind complete, forgetting peer') |
| 3488 | |
| 3489 | |
| 3490 | def test_permfail_htlc_out(node_factory, bitcoind, executor): |
nothing calls this directly
no test coverage detected