pytest: disable autoreconnect on test_sql to avoid reconnect race.
What changed, and why it matters
This commit is a test-only fix. It changes three test files to make automated tests more reliable: it disables automatic reconnections in one test to avoid a timing race, fixes a typo in a log message another test waits for, and adds a short sleep in a third test. There is no change to the actual Core Lightning node software that users run, so it does not affect real network security.
No security action needed. Treat as routine test reliability improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies three pytest files. In tests/test_plugin.py, the test_sql fixture now passes dev-no-reconnect to nodes l1, l2, and l3, preventing them from auto-reconnecting because dev-allow-localhost lets localhost be treated as a public/broadcastable address. This avoids a race where l2.rpc.connect(l3…) fails with ‘disconnected during connection’. tests/test_coinmoves.py fixes a log string typo (‘chainmovesmoves’ -> ‘chainmoves’). tests/test_invoices.py adds time.sleep(1) before an autoclean RPC call to reduce flakiness. No production code is changed.
Changed components
tests/test_plugin.pytests/test_invoices.pytests/test_coinmoves.pyInspect captured patch +6 / −3
diff --git a/tests/test_coinmoves.py b/tests/test_coinmoves.py
index bc7ee41d..160654fa 100644
--- a/tests/test_coinmoves.py
+++ b/tests/test_coinmoves.py
@@ -1938,7 +1938,7 @@ def test_wait(node_factory, bitcoind, executor):
l1, l2 = node_factory.get_nodes(2)
fut = executor.submit(l1.rpc.wait, subsystem='chainmoves', indexname='created', nextvalue=1)
- l1.daemon.wait_for_log('waiting on chainmovesmoves created 1')
+ l1.daemon.wait_for_log('waiting on chainmoves created 1')
addr = l1.rpc.newaddr('bech32')['bech32']
bitcoind.rpc.sendtoaddress(addr, 200000000 / 10**8)
diff --git a/tests/test_invoices.py b/tests/test_invoices.py
index 29c35fc4..9a89af9c 100644
--- a/tests/test_invoices.py
+++ b/tests/test_invoices.py
@@ -742,6 +742,7 @@ def test_wait_invoices(node_factory, executor):
# Now check autoclean works.
waitfut = executor.submit(l2.rpc.call, 'wait', {'subsystem': 'invoices', 'indexname': 'deleted', 'nextvalue': 2})
l2.daemon.wait_for_log('waiting on invoices deleted 2')
+ time.sleep(1)
l2.rpc.autoclean_once('expiredinvoices', 1)
waitres = waitfut.result(TIMEOUT)
diff --git a/tests/test_plugin.py b/tests/test_plugin.py
index 78f6d849..6e2a94ff 100644
--- a/tests/test_plugin.py
+++ b/tests/test_plugin.py
@@ -3254,14 +3254,16 @@ def test_block_added_notifications(node_factory, bitcoind):
def test_sql(node_factory, bitcoind):
opts = {'experimental-dual-fund': None,
'dev-allow-localhost': None,
- 'may_reconnect': True}
+ 'may_reconnect': True,
+ 'dev-no-reconnect': None}
l2opts = {'lease-fee-basis': 50,
'experimental-dual-fund': None,
'lease-fee-base-sat': '2000msat',
'channel-fee-max-base-msat': '500sat',
'channel-fee-max-proportional-thousandths': 200,
'dev-sqlfilename': 'sql.sqlite3',
- 'may_reconnect': True}
+ 'may_reconnect': True,
+ 'dev-no-reconnect': None}
l2opts.update(opts)
l1, l2, l3 = node_factory.line_graph(3, wait_for_announce=True,
opts=[opts, l2opts, opts])
Why this scored 13/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.