mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-02 18:35:00 +01:00
pytest: Add a test to reproduce #3748
This commit is contained in:
parent
160c564e5f
commit
3d6c4e93b3
2 changed files with 44 additions and 0 deletions
14
tests/plugins/htlc_accepted-crash.py
Executable file
14
tests/plugins/htlc_accepted-crash.py
Executable file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
from pyln.client import Plugin
|
||||||
|
|
||||||
|
|
||||||
|
plugin = Plugin()
|
||||||
|
|
||||||
|
|
||||||
|
@plugin.hook('htlc_accepted')
|
||||||
|
def on_htlc_accepted(plugin, **kwargs):
|
||||||
|
plugin.log("Crashing on purpose...")
|
||||||
|
raise ValueError()
|
||||||
|
|
||||||
|
|
||||||
|
plugin.run()
|
|
@ -1858,3 +1858,33 @@ def test_important_plugin(node_factory):
|
||||||
def test_dev_builtin_plugins_unimportant(node_factory):
|
def test_dev_builtin_plugins_unimportant(node_factory):
|
||||||
n = node_factory.get_node(options={"dev-builtin-plugins-unimportant": None})
|
n = node_factory.get_node(options={"dev-builtin-plugins-unimportant": None})
|
||||||
n.rpc.plugin_stop(plugin="pay")
|
n.rpc.plugin_stop(plugin="pay")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.xfail(strict=True)
|
||||||
|
def test_htlc_accepted_hook_crash(node_factory, executor):
|
||||||
|
"""Test that we do not hang incoming HTLCs if the hook plugin crashes.
|
||||||
|
|
||||||
|
Reproduces #3748.
|
||||||
|
"""
|
||||||
|
plugin = os.path.join(os.getcwd(), 'tests/plugins/htlc_accepted-crash.py')
|
||||||
|
l1 = node_factory.get_node()
|
||||||
|
l2 = node_factory.get_node(
|
||||||
|
options={'plugin': plugin},
|
||||||
|
allow_broken_log=True
|
||||||
|
)
|
||||||
|
l1.connect(l2)
|
||||||
|
l1.fund_channel(l2, 10**6)
|
||||||
|
|
||||||
|
i = l2.rpc.invoice(500, "crashpls", "crashpls")['bolt11']
|
||||||
|
|
||||||
|
# This should still succeed
|
||||||
|
|
||||||
|
f = executor.submit(l1.rpc.pay, i)
|
||||||
|
|
||||||
|
l2.daemon.wait_for_log(r'Crashing on purpose...')
|
||||||
|
l2.daemon.wait_for_log(
|
||||||
|
r'Hook handler for htlc_accepted failed with an exception.'
|
||||||
|
)
|
||||||
|
|
||||||
|
with pytest.raises(RpcError, match=r'failed: WIRE_TEMPORARY_NODE_FAILURE'):
|
||||||
|
f.result(10)
|
||||||
|
|
Loading…
Add table
Reference in a new issue