mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 10:46:58 +01:00
pytest: Reproduce issue #3403, sendpay notifications with no waiter
We clone the test above, but this time we don't attach waiters (they'd be racy anyway), and we wait for the notification to be called. This fails, but is fixed in the next two commits.
This commit is contained in:
parent
2d45b13088
commit
cc37862273
2 changed files with 28 additions and 2 deletions
|
@ -14,13 +14,13 @@ def init(configuration, options, plugin):
|
||||||
|
|
||||||
@plugin.subscribe("sendpay_success")
|
@plugin.subscribe("sendpay_success")
|
||||||
def notify_sendpay_success(plugin, sendpay_success):
|
def notify_sendpay_success(plugin, sendpay_success):
|
||||||
plugin.log("receive a sendpay_success recored, id: {}, payment_hash: {}".format(sendpay_success['id'], sendpay_success['payment_hash']))
|
plugin.log("Received a sendpay_success: id={}, payment_hash={}".format(sendpay_success['id'], sendpay_success['payment_hash']))
|
||||||
plugin.success_list.append(sendpay_success)
|
plugin.success_list.append(sendpay_success)
|
||||||
|
|
||||||
|
|
||||||
@plugin.subscribe("sendpay_failure")
|
@plugin.subscribe("sendpay_failure")
|
||||||
def notify_sendpay_failure(plugin, sendpay_failure):
|
def notify_sendpay_failure(plugin, sendpay_failure):
|
||||||
plugin.log("receive a sendpay_failure recored, id: {}, payment_hash: {}".format(sendpay_failure['data']['id'],
|
plugin.log("Received a sendpay_failure: id={}, payment_hash={}".format(sendpay_failure['data']['id'],
|
||||||
sendpay_failure['data']['payment_hash']))
|
sendpay_failure['data']['payment_hash']))
|
||||||
plugin.failure_list.append(sendpay_failure)
|
plugin.failure_list.append(sendpay_failure)
|
||||||
|
|
||||||
|
|
|
@ -758,6 +758,32 @@ def test_sendpay_notifications(node_factory, bitcoind):
|
||||||
assert results['sendpay_failure'][0] == err.value.error
|
assert results['sendpay_failure'][0] == err.value.error
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.xfail(strict=True)
|
||||||
|
def test_sendpay_notifications_nowaiter(node_factory):
|
||||||
|
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)
|
||||||
|
amount = 10**8
|
||||||
|
|
||||||
|
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)
|
||||||
|
l1.daemon.wait_for_log(r'Received a sendpay_success')
|
||||||
|
|
||||||
|
l2.rpc.close(chanid23, 1)
|
||||||
|
|
||||||
|
l1.rpc.sendpay(route, payment_hash2)
|
||||||
|
l1.daemon.wait_for_log(r'Received a sendpay_failure')
|
||||||
|
|
||||||
|
results = l1.rpc.call('listsendpays_plugin')
|
||||||
|
assert len(results['sendpay_success']) == 1
|
||||||
|
assert len(results['sendpay_failure']) == 1
|
||||||
|
|
||||||
|
|
||||||
def test_rpc_command_hook(node_factory):
|
def test_rpc_command_hook(node_factory):
|
||||||
"""Test the `sensitive_command` hook"""
|
"""Test the `sensitive_command` hook"""
|
||||||
plugin = os.path.join(os.getcwd(), "tests/plugins/rpc_command.py")
|
plugin = os.path.join(os.getcwd(), "tests/plugins/rpc_command.py")
|
||||||
|
|
Loading…
Add table
Reference in a new issue