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

Function test_sendpay_notifications

tests/test_plugin.py:1716–1746  ·  view source on GitHub ↗

test 'sendpay_success' and 'sendpay_failure' notifications

(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

1714
1715
1716def test_sendpay_notifications(node_factory, bitcoind):
1717 """ test 'sendpay_success' and 'sendpay_failure' notifications
1718 """
1719 amount = 10**8
1720 opts = [{'plugin': os.path.join(os.getcwd(), 'tests/plugins/sendpay_notifications.py')},
1721 {},
1722 {'may_reconnect': False}]
1723 l1, l2, l3 = node_factory.line_graph(3, opts=opts, wait_for_announce=True)
1724 chanid23 = l2.get_channel_scid(l3)
1725
1726 inv1 = l3.rpc.invoice(amount, "first", "desc")
1727 payment_hash1 = inv1['payment_hash']
1728 inv2 = l3.rpc.invoice(amount, "second", "desc")
1729 payment_hash2 = inv2['payment_hash']
1730 route = l1.single_route(l3.info['id'], amount)
1731
1732 l1.rpc.sendpay(route, payment_hash1, payment_secret=inv1['payment_secret'])
1733 response1 = l1.rpc.waitsendpay(payment_hash1)
1734
1735 l2.rpc.close(chanid23, 1)
1736
1737 l1.rpc.sendpay(route, payment_hash2, payment_secret=inv2['payment_secret'])
1738 with pytest.raises(RpcError) as err:
1739 l1.rpc.waitsendpay(payment_hash2)
1740
1741 results = l1.rpc.call('listsendpays_plugin')
1742 assert len(results['sendpay_success']) == 1
1743 assert len(results['sendpay_failure']) == 1
1744
1745 assert results['sendpay_success'][0] == response1
1746 assert results['sendpay_failure'][0] == err.value.error
1747
1748
1749def test_sendpay_notifications_nowaiter(node_factory):

Callers

nothing calls this directly

Calls 9

joinMethod · 0.80
line_graphMethod · 0.80
get_channel_scidMethod · 0.80
single_routeMethod · 0.80
sendpayMethod · 0.80
waitsendpayMethod · 0.80
invoiceMethod · 0.45
closeMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected