mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
pytest: Add a test for 'sendpay_success' and 'sendpay_failure'
This commit is contained in:
committed by
Rusty Russell
parent
5fa3a50896
commit
619362ae19
@@ -708,3 +708,34 @@ def test_plugin_deprecated_relpath(node_factory):
|
||||
assert l1.daemon.is_in_log('DEPRECATED WARNING.*plugin={}'
|
||||
.format(os.path.join(os.getcwd(),
|
||||
'tests/plugins/millisatoshis.py')))
|
||||
|
||||
|
||||
def test_sendpay_notifications(node_factory, bitcoind):
|
||||
""" test 'sendpay_success' and 'sendpay_failure' notifications
|
||||
"""
|
||||
amount = 10**8
|
||||
opts = [{'plugin': os.path.join(os.getcwd(), 'tests/plugins/sendpay_notifications.py')},
|
||||
{},
|
||||
{'may_reconnect': False}]
|
||||
l1, l2, l3 = node_factory.line_graph(3, opts=opts, wait_for_announce=True)
|
||||
chanid23 = l2.get_channel_scid(l3)
|
||||
|
||||
payment_hash1 = l3.rpc.invoice(amount, "first", "desc")['payment_hash']
|
||||
payment_hash2 = l3.rpc.invoice(amount, "second", "desc")['payment_hash']
|
||||
route = l1.rpc.getroute(l3.info['id'], amount, 1)['route']
|
||||
|
||||
l1.rpc.sendpay(route, payment_hash1)
|
||||
response1 = l1.rpc.waitsendpay(payment_hash1)
|
||||
|
||||
l2.rpc.close(chanid23, 1)
|
||||
|
||||
l1.rpc.sendpay(route, payment_hash2)
|
||||
with pytest.raises(RpcError) as err:
|
||||
l1.rpc.waitsendpay(payment_hash2)
|
||||
|
||||
results = l1.rpc.call('listsendpays_plugin')
|
||||
assert len(results['sendpay_success']) == 1
|
||||
assert len(results['sendpay_failure']) == 1
|
||||
|
||||
assert results['sendpay_success'][0] == response1
|
||||
assert results['sendpay_failure'][0] == err.value.error
|
||||
|
||||
Reference in New Issue
Block a user