pytest: test failure if we crash after fundchannel_complete but before sendpsbt.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2025-11-18 14:39:04 +10:30
parent d44fa2f3bd
commit 409beb6923
2 changed files with 40 additions and 0 deletions

21
tests/plugins/stop_sendpsbt.py Executable file
View File

@@ -0,0 +1,21 @@
#!/usr/bin/env python3
"""
This plugin is used to shutdown a node before processing the sendpsbt command
"""
from pyln.client import Plugin
import os
import signal
plugin = Plugin()
@plugin.hook("rpc_command")
def on_rpc_command(plugin, rpc_command, **kwargs):
request = rpc_command
if request["method"] == "sendpsbt":
os.kill(os.getppid(), signal.SIGKILL)
return {"result": "continue"}
plugin.run()

View File

@@ -2847,3 +2847,22 @@ def test_opening_crash(bitcoind, node_factory):
l1.start()
bitcoind.generate_block(1, wait_for_mempool=txid)
@pytest.mark.xfail(strict=True)
@pytest.mark.openchannel('v1')
def test_sendpsbt_crash(bitcoind, node_factory):
"""Stop sendpsbt, check it eventually opens"""
plugin_path = Path(__file__).parent / "plugins" / "stop_sendpsbt.py"
l1, l2 = node_factory.get_nodes(2, opts=[{"plugin": plugin_path, 'may_fail': True}, {}])
l1.fundwallet(3_000_000)
l1.connect(l2)
# signpsbt kills l1.
with pytest.raises(RpcError, match=r'Connection to RPC server lost.'):
l1.rpc.fundchannel(l2.info['id'], "2000000sat")
del l1.daemon.opts['plugin']
l1.start()
bitcoind.generate_block(1, wait_for_mempool=1)