pytest: really fix race in test_buy_liquidity_ad_check_bookkeeping
What changed, and why it matters
This is a fix to a flaky automated test, not a security fix. The test was checking whether all channels are active before continuing, but the check accidentally returned 'true' when there were no channels at all (because 'all([])' is true in Python). The patch now explicitly waits for exactly two channels and both to be active. It does not change production code or address any vulnerability.
No security action required. 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_opening.py in the Core Lightning test suite. The previous wait_for predicate used all([c[‘active’] for c in n.rpc.listchannels()[‘channels’]]), which evaluates to True when the channels list is empty, causing a race where the test could proceed before gossip had populated the channels. The replacement checks that the list equals [True, True], ensuring exactly two channels exist and are active. No C/lightningd source code is changed.
Changed components
tests/test_opening.py::test_buy_liquidity_ad_check_bookkeepingInspect captured patch +1 / −1
diff --git a/tests/test_opening.py b/tests/test_opening.py
index 8348ba2f..47db560a 100644
--- a/tests/test_opening.py
+++ b/tests/test_opening.py
@@ -1949,7 +1949,7 @@ def test_buy_liquidity_ad_check_bookkeeping(node_factory, bitcoind):
# Avoid bad gossip messages caused by channel announcements being
# processed after closing.
for n in (l1, l2):
- wait_for(lambda: all([c['active'] for c in n.rpc.listchannels()['channels']]))
+ wait_for(lambda: [c['active'] for c in n.rpc.listchannels()['channels']] == [True, True])
chan_id = first_channel_id(l1, l2)
ev_tags = [e['tag'] for e in l1.rpc.bkpr_listaccountevents(chan_id)['events']]
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.