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

Function test_sendpays_wait

tests/test_pay.py:5701–5802  ·  view source on GitHub ↗
(node_factory, executor)

Source from the content-addressed store, hash-verified

5699
5700
5701def test_sendpays_wait(node_factory, executor):
5702 l1, l2 = node_factory.line_graph(2)
5703
5704 waitres = l1.rpc.wait(subsystem='sendpays', indexname='created', nextvalue=0)
5705 assert waitres == {'subsystem': 'sendpays',
5706 'created': 0}
5707
5708 # Now ask for 1.
5709 waitfut = executor.submit(l1.rpc.wait, subsystem='sendpays', indexname='created', nextvalue=1)
5710 l1.daemon.wait_for_log('waiting on sendpays created 1')
5711
5712 inv1 = l2.rpc.invoice(42, 'invlabel', 'invdesc')
5713 l1.rpc.xpay(inv1['bolt11'])
5714
5715 waitres = waitfut.result(TIMEOUT)
5716 # groupid is random
5717 groupid = waitres['sendpays']['groupid']
5718 assert waitres == {'subsystem': 'sendpays',
5719 'created': 1,
5720 'sendpays': {'status': 'pending',
5721 'partid': 1,
5722 'groupid': groupid,
5723 'payment_hash': inv1['payment_hash']}}
5724 assert only_one(l1.rpc.listsendpays(bolt11=inv1['bolt11'])['payments'])['created_index'] == 1
5725 assert only_one(l1.rpc.listsendpays(bolt11=inv1['bolt11'])['payments'])['updated_index'] == 1
5726
5727 # Second returns instantly, without any details.
5728 waitres = l1.rpc.wait(subsystem='sendpays', indexname='created', nextvalue=1)
5729 assert waitres == {'subsystem': 'sendpays',
5730 'created': 1}
5731
5732 # Now for updates
5733 waitres = l1.rpc.wait(subsystem='sendpays', indexname='updated', nextvalue=0)
5734 assert waitres == {'subsystem': 'sendpays',
5735 'updated': 1}
5736
5737 inv2 = l2.rpc.invoice(42, 'invlabel2', 'invdesc2')
5738
5739 waitfut = executor.submit(l1.rpc.wait, subsystem='sendpays', indexname='updated', nextvalue=2)
5740 l1.daemon.wait_for_log('waiting on sendpays updated 2')
5741 l1.rpc.xpay(inv2['bolt11'])
5742 waitres = waitfut.result(TIMEOUT)
5743 groupid = waitres['sendpays']['groupid']
5744 assert waitres == {'subsystem': 'sendpays',
5745 'updated': 2,
5746 'sendpays': {'status': 'complete',
5747 'partid': 1,
5748 'groupid': groupid,
5749 'payment_hash': inv2['payment_hash']}}
5750 assert only_one(l1.rpc.listsendpays(bolt11=inv2['bolt11'])['payments'])['created_index'] == 2
5751 assert only_one(l1.rpc.listsendpays(bolt11=inv2['bolt11'])['payments'])['updated_index'] == 2
5752
5753 # Second returns instantly, without any details.
5754 waitres = l1.rpc.wait(subsystem='sendpays', indexname='updated', nextvalue=2)
5755 assert waitres == {'subsystem': 'sendpays',
5756 'updated': 2}
5757
5758 # Now check failure.

Callers

nothing calls this directly

Calls 8

only_oneFunction · 0.90
line_graphMethod · 0.80
wait_for_logMethod · 0.80
listsendpaysMethod · 0.80
delinvoiceMethod · 0.80
waitMethod · 0.45
invoiceMethod · 0.45
xpayMethod · 0.45

Tested by

no test coverage detected