pytest: fix timeout flake in test_dataloss_protection
What changed, and why it matters
This commit fixes a flaky automated test, not a security bug. The test was sometimes timing out because one node kept waiting longer and longer to reconnect after the other node restarted. The fix manually triggers a reconnect so the test completes faster and more reliably. There is no change to production code or user-facing behavior.
No security action required. Treat as a normal test reliability improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch adds a single l1.rpc.connect(...) call in tests/test_connection.py::test_dataloss_protection. The test restarts l2 twice; each restart causes l1 to attempt reconnection with exponential backoff capped at 300 s. On slow CI runners the accumulated backoff could exceed the test timeout, producing a flake. The manual reconnect resets the connection attempt immediately, shortening runtime and avoiding the timeout. No daemon, protocol, or library code is modified.
Changed components
tests/test_connection.pyInspect captured patch +6 / −0
diff --git a/tests/test_connection.py b/tests/test_connection.py
index 5dd5b768..07e38ccb 100644
--- a/tests/test_connection.py
+++ b/tests/test_connection.py
@@ -3081,6 +3081,12 @@ def test_dataloss_protection(node_factory, bitcoind):
Path(dbpath).write_bytes(orig_db)
l2.start()
+ # l1 will keep trying to reconnect, but it's using exponential backoff,
+ # which only gets reset after the connection has lasted MAX_WAIT_SECONDS (300)
+ # which it hasn't. Speed things up (and avoid a timeout flake!) by reconnecting
+ # manually now.
+ l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
+
# l2 should freak out!
l2.daemon.wait_for_log("Peer permanent failure in CHANNELD_NORMAL:.*Awaiting unilateral close")
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.