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:
21
tests/plugins/stop_sendpsbt.py
Executable file
21
tests/plugins/stop_sendpsbt.py
Executable 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()
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user