Skip to content

Commit 409beb6

Browse files
committed
pytest: test failure if we crash after fundchannel_complete but before sendpsbt.
Signed-off-by: Rusty Russell <[email protected]>
1 parent d44fa2f commit 409beb6

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

tests/plugins/stop_sendpsbt.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env python3
2+
"""
3+
This plugin is used to shutdown a node before processing the sendpsbt command
4+
"""
5+
from pyln.client import Plugin
6+
import os
7+
import signal
8+
9+
plugin = Plugin()
10+
11+
12+
@plugin.hook("rpc_command")
13+
def on_rpc_command(plugin, rpc_command, **kwargs):
14+
request = rpc_command
15+
if request["method"] == "sendpsbt":
16+
os.kill(os.getppid(), signal.SIGKILL)
17+
18+
return {"result": "continue"}
19+
20+
21+
plugin.run()

tests/test_opening.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2847,3 +2847,22 @@ def censoring_sendrawtx(r):
28472847
l1.start()
28482848

28492849
bitcoind.generate_block(1, wait_for_mempool=txid)
2850+
2851+
2852+
@pytest.mark.xfail(strict=True)
2853+
@pytest.mark.openchannel('v1')
2854+
def test_sendpsbt_crash(bitcoind, node_factory):
2855+
"""Stop sendpsbt, check it eventually opens"""
2856+
plugin_path = Path(__file__).parent / "plugins" / "stop_sendpsbt.py"
2857+
l1, l2 = node_factory.get_nodes(2, opts=[{"plugin": plugin_path, 'may_fail': True}, {}])
2858+
2859+
l1.fundwallet(3_000_000)
2860+
l1.connect(l2)
2861+
2862+
# signpsbt kills l1.
2863+
with pytest.raises(RpcError, match=r'Connection to RPC server lost.'):
2864+
l1.rpc.fundchannel(l2.info['id'], "2000000sat")
2865+
2866+
del l1.daemon.opts['plugin']
2867+
l1.start()
2868+
bitcoind.generate_block(1, wait_for_mempool=1)

0 commit comments

Comments
 (0)