MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_permfail_htlc_out

Function test_permfail_htlc_out

tests/test_closing.py:3490–3548  ·  view source on GitHub ↗
(node_factory, bitcoind, executor)

Source from the content-addressed store, hash-verified

3488
3489
3490def test_permfail_htlc_out(node_factory, bitcoind, executor):
3491 # Test case where we fail with unsettled outgoing HTLC.
3492 disconnects = ['+WIRE_REVOKE_AND_ACK', 'permfail']
3493 l1 = node_factory.get_node(options={'dev-no-reconnect': None})
3494 # Feerates identical so we don't get gratuitous commit to update them
3495 l2 = node_factory.get_node(disconnect=disconnects,
3496 feerates=(7500, 7500, 7500, 7500))
3497
3498 l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
3499 l2.daemon.wait_for_log('Handed peer, entering loop')
3500 l2.fundchannel(l1, 10**6)
3501
3502 # This will fail at l2's end.
3503 t = executor.submit(l2.pay, l1, 200000000)
3504
3505 l2.daemon.wait_for_log('dev_disconnect permfail')
3506 l2.wait_for_channel_onchain(l1.info['id'])
3507 bitcoind.generate_block(1)
3508 l1.daemon.wait_for_log('Their unilateral tx, old commit point')
3509 l1.daemon.wait_for_log(' to ONCHAIN')
3510 l2.daemon.wait_for_log(' to ONCHAIN')
3511
3512 # Could happen any order
3513 ((_, _, blocks1), (_, txid2, blocks2)) = \
3514 l2.wait_for_onchaind_txs(('OUR_HTLC_TIMEOUT_TX',
3515 'OUR_UNILATERAL/OUR_HTLC'),
3516 ('OUR_DELAYED_RETURN_TO_WALLET',
3517 'OUR_UNILATERAL/DELAYED_OUTPUT_TO_US'))
3518 assert blocks1 == 5
3519 assert blocks2 == 4
3520
3521 l1.daemon.wait_for_log(r'Propose ignoring THEIR_UNILATERAL/THEIR_HTLC as THEIR_HTLC_TIMEOUT_TO_THEM after block [0-9]* \(5 more blocks\)')
3522 # l1 then gets preimage, uses it instead of ignoring
3523 _, txid1, blocks = l1.wait_for_onchaind_tx('THEIR_HTLC_FULFILL_TO_US',
3524 'THEIR_UNILATERAL/THEIR_HTLC')
3525 assert blocks == 0
3526 # l2 sees l1 fulfill tx.
3527 bitcoind.generate_block(1, wait_for_mempool=txid1)
3528
3529 l2.daemon.wait_for_log('OUR_UNILATERAL/OUR_HTLC gave us preimage')
3530 t.cancel()
3531
3532 # l2 can send OUR_DELAYED_RETURN_TO_WALLET after 4 more blocks.
3533 bitcoind.generate_block(3)
3534
3535 # Now, 100 blocks they should be done.
3536 bitcoind.generate_block(95, txid2)
3537 sync_blockheight(bitcoind, [l1, l2])
3538 assert not l1.daemon.is_in_log('onchaind complete, forgetting peer')
3539 assert not l2.daemon.is_in_log('onchaind complete, forgetting peer')
3540 bitcoind.generate_block(1)
3541 l1.daemon.wait_for_log('onchaind complete, forgetting peer')
3542 sync_blockheight(bitcoind, [l2])
3543 assert not l2.daemon.is_in_log('onchaind complete, forgetting peer')
3544 bitcoind.generate_block(3)
3545 sync_blockheight(bitcoind, [l2])
3546 assert not l2.daemon.is_in_log('onchaind complete, forgetting peer')
3547 bitcoind.generate_block(2)

Callers

nothing calls this directly

Calls 12

sync_blockheightFunction · 0.90
wait_forFunction · 0.90
wait_for_logMethod · 0.80
generate_blockMethod · 0.80
wait_for_onchaind_txsMethod · 0.80
wait_for_onchaind_txMethod · 0.80
is_in_logMethod · 0.80
get_nodeMethod · 0.45
connectMethod · 0.45
fundchannelMethod · 0.45
listpeersMethod · 0.45

Tested by

no test coverage detected