tests: fix flaky test_sql blockheight race
What changed, and why it matters
This commit fixes a flaky test, not a security vulnerability. The test sometimes failed because one node was slower to process newly mined blocks than the others, causing payment route expiry values to be rejected. The fix simply waits for all test nodes to catch up to the same block height before making payments. There is no product bug being patched and no security relevance.
No security action required. Treat as a routine test reliability fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change adds a sync_blockheight(bitcoind, [l1, l2, l3]) call in tests/test_plugin.py::test_sql after a burst of ~106 generated blocks and before three xpay payments. The race occurred under valgrind when the paying node lagged behind bitcoind, producing onion CLTV expiries that caught-up peers rejected as expiry_too_soon. This is a test-only synchronization fix; no production code is modified.
Changed components
tests/test_plugin.py::test_sqlInspect captured patch +5 / −0
diff --git a/tests/test_plugin.py b/tests/test_plugin.py
index 0025d4c3..8d2c7f43 100644
--- a/tests/test_plugin.py
+++ b/tests/test_plugin.py
@@ -4359,6 +4359,11 @@ def test_sql(node_factory, bitcoind):
# Make sure we have a node_announcement for l1
wait_for(lambda: l2.rpc.listnodes(l1.info['id'])['nodes'] != [])
+ # Under valgrind, the senders can still be digesting the blocks
+ # above and pick a stale blockheight for the payments below, which
+ # the caught-up peers reject as expiry_too_soon.
+ sync_blockheight(bitcoind, [l1, l2, l3])
+
# This should create a forward through l2
l1.rpc.xpay(l3.rpc.invoice(amount_msat=12300, label='inv1', description='description')['bolt11'])
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.