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

Function test_listhtlcs_wait

tests/test_misc.py:3710–3786  ·  view source on GitHub ↗
(node_factory, bitcoind, executor)

Source from the content-addressed store, hash-verified

3708
3709
3710def test_listhtlcs_wait(node_factory, bitcoind, executor):
3711 l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True)
3712
3713 scid12 = first_scid(l1, l2)
3714 scid23 = first_scid(l2, l3)
3715 waitres = l1.rpc.wait(subsystem='htlcs', indexname='created', nextvalue=0)
3716 assert waitres == {'subsystem': 'htlcs',
3717 'created': 0}
3718
3719 # Now ask for 1.
3720 waitcreate = executor.submit(l2.rpc.wait, subsystem='htlcs', indexname='created', nextvalue=1)
3721 waitupdate = executor.submit(l2.rpc.wait, subsystem='htlcs', indexname='updated', nextvalue=1)
3722 l2.daemon.wait_for_logs(['waiting on htlcs created 1', 'waiting on htlcs updated 1'])
3723
3724 amt1 = 1000
3725 inv1 = l3.rpc.invoice(amt1, 'inv1', 'desc')
3726 l1.rpc.xpay(invstring=inv1['bolt11'], dev_use_shadow=False)
3727
3728 waitres = waitcreate.result(TIMEOUT)
3729 assert waitres == {'subsystem': 'htlcs',
3730 'created': 1,
3731 'htlcs': {'short_channel_id': scid12,
3732 'cltv_expiry': 120,
3733 'direction': 'in',
3734 'htlc_id': 0,
3735 'payment_hash': inv1['payment_hash'],
3736 'amount_msat': amt1 + 1,
3737 'state': 'RCVD_ADD_COMMIT'}}
3738 waitres = waitupdate.result(TIMEOUT)
3739 assert waitres == {'subsystem': 'htlcs',
3740 'updated': 1,
3741 'htlcs': {'short_channel_id': scid12,
3742 'cltv_expiry': 120,
3743 'direction': 'in',
3744 'htlc_id': 0,
3745 'payment_hash': inv1['payment_hash'],
3746 'amount_msat': amt1 + 1,
3747 'state': 'SENT_ADD_REVOCATION'}}
3748
3749 # There's a second new one too, for the outgoing, but we missed details
3750 assert l2.rpc.wait(subsystem='htlcs', indexname='created', nextvalue=2) == {'created': 2, 'subsystem': 'htlcs'}
3751
3752 # Now check failure, and wait for OUTGOING.
3753 amt2 = 42
3754 inv2 = l3.rpc.invoice(amt2, 'inv2', 'invdesc2')
3755 l3.rpc.delinvoice('inv2', 'unpaid')
3756
3757 waitcreate = executor.submit(l2.rpc.wait, subsystem='htlcs', indexname='created', nextvalue=4)
3758 l2.daemon.wait_for_log('waiting on htlcs created 4')
3759
3760 with pytest.raises(RpcError, match="incorrect_or_unknown_payment_details"):
3761 l1.rpc.xpay(inv2['bolt11'], dev_use_shadow=False)
3762
3763 waitres = waitcreate.result(TIMEOUT)
3764 assert waitres == {'subsystem': 'htlcs',
3765 'created': 4,
3766 'htlcs': {'short_channel_id': scid23,
3767 'cltv_expiry': 114,

Callers

nothing calls this directly

Calls 10

first_scidFunction · 0.90
line_graphMethod · 0.80
wait_for_logsMethod · 0.80
delinvoiceMethod · 0.80
wait_for_logMethod · 0.80
generate_blockMethod · 0.80
waitMethod · 0.45
invoiceMethod · 0.45
xpayMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected