pytest: don't record IO when we kill nodes
What changed, and why it matters
This change only adjusts two test cases so they no longer save plugin input/output logs before deliberately crashing a test node. It fixes flaky test failures where reading a partially-written JSON file produced a decode error. It does not change any production code or affect real users.
No security action needed. This is a test reliability fix; review and merge as normal.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies tests/test_connection.py and tests/test_opening.py. In each test, the node is created with start=False, the ‘dev-save-plugin-io’ developer option is removed from the daemon options, and then the node is started. This prevents the test harness from recording plugin IO, which could be truncated when the node is killed and later parsed as JSON, causing json.decoder.JSONDecodeError. The change is purely test-hardening.
Changed components
tests/test_connection.pytests/test_opening.pyInspect captured patch +10 / −2
diff --git a/tests/test_connection.py b/tests/test_connection.py
index 7a3e85f..92603ea 100644
--- a/tests/test_connection.py
+++ b/tests/test_connection.py
@@ -2293,7 +2293,11 @@ def test_channel_persistence(node_factory, bitcoind, executor):
l1 = node_factory.get_node(may_reconnect=True, feerates=(7500, 7500, 7500,
7500))
l2 = node_factory.get_node(options={'dev-disable-commit-after': disable_commit_after},
- may_reconnect=True)
+ may_reconnect=True, start=False)
+ # Saving IO can cause JSON errors when we check it, due to partial writes if we
+ # get lucky when we kill it.
+ del l2.daemon.opts['dev-save-plugin-io']
+ l2.start()
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
# Neither node should have a channel open, they are just connected
diff --git a/tests/test_opening.py b/tests/test_opening.py
index b1bf940..a8090f9 100644
--- a/tests/test_opening.py
+++ b/tests/test_opening.py
@@ -2858,7 +2858,11 @@ def test_opening_crash(bitcoind, node_factory):
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, l2 = node_factory.get_nodes(2, opts=[{"plugin": plugin_path, 'may_fail': True, 'start': False}, {}])
+ # Saving IO can cause JSON errors when we check it, due to partial writes if we
+ # get lucky when we kill it.
+ del l1.daemon.opts['dev-save-plugin-io']
+ l1.start()
l1.fundwallet(3_000_000)
l1.connect(l2)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.