pytest: allow pushed after onchain_fee in test_bookkeeping_missed_chans_pushed
What changed, and why it matters
This is a test-only change that makes a bookkeeping test accept either of two possible event orderings. It does not change production code, network behavior, or security properties. There is no vulnerability or security fix here.
No security action needed. Treat as a routine test-maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies tests/test_bookkeeper.py to allow the ‘onchain_fee’ and ‘pushed’ events to appear in either order in test_bookkeeping_missed_chans_pushed. The helper check_events now accepts an optional alt_events list and asserts the observed events match either the original or alternative ordering. This is purely a test-flake fix; no Core Lightning runtime code is touched.
Changed components
tests/test_bookkeeper.pyInspect captured patch +8 / −3
diff --git a/tests/test_bookkeeper.py b/tests/test_bookkeeper.py
index 5160261e..d2a2e714 100644
--- a/tests/test_bookkeeper.py
+++ b/tests/test_bookkeeper.py
@@ -23,10 +23,10 @@ def find_first_tag(evs, tag):
return ev[0]
-def check_events(node, channel_id, exp_events):
+def check_events(node, channel_id, exp_events, alt_events=None):
chan_events = [ev for ev in node.rpc.bkpr_listaccountevents()['events'] if ev['account'] == channel_id]
stripped = [{k: d[k] for k in ('tag', 'credit_msat', 'debit_msat') if k in d} for d in chan_events]
- assert stripped == exp_events
+ assert stripped == exp_events or stripped == alt_events
@unittest.skipIf(TEST_NETWORK != 'regtest', "fixme: broadcast fails, dusty")
@@ -399,7 +399,12 @@ def test_bookkeeping_missed_chans_pushed(node_factory, bitcoind):
{'tag': 'pushed', 'credit_msat': 0, 'debit_msat': push_amt},
{'tag': 'onchain_fee', 'credit_msat': 4927000, 'debit_msat': 0},
{'tag': 'invoice', 'credit_msat': 0, 'debit_msat': invoice_msat}]
- check_events(l1, channel_id, exp_events)
+ # We sometimes see onchain_fee first:
+ alt_events = [{'tag': 'channel_open', 'credit_msat': open_amt * 1000, 'debit_msat': 0},
+ {'tag': 'onchain_fee', 'credit_msat': 4927000, 'debit_msat': 0},
+ {'tag': 'pushed', 'credit_msat': 0, 'debit_msat': push_amt},
+ {'tag': 'invoice', 'credit_msat': 0, 'debit_msat': invoice_msat}]
+ check_events(l1, channel_id, exp_events, alt_events)
# l2 events
exp_events = [{'tag': 'channel_open', 'credit_msat': 0, 'debit_msat': 0},
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.