test: don't always assert NUM_PRIVATE_BROADCAST_PER_TX broadcasts
What changed, and why it matters
This is a one-line fix in a Bitcoin Core test script. It changes a test assertion to check the correct expected number of peer broadcasts, preventing a flaky test failure. It does not change any production code or network behavior, so it has no security impact on users.
No security action needed; this is a test-only reliability fix. Reviewers can merge as a normal test improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In test/functional/p2p_private_broadcast.py, the check_broadcasts() helper was asserting that at least NUM_PRIVATE_BROADCAST_PER_TX peers had received a broadcast. In the ‘Basic’ test, the first broadcast is verified separately and may still be in flight when check_broadcasts() is called for the remaining two, causing an intermittent assertion failure (2 < 3). The patch changes the assertion to compare against the broadcasts_to_expect parameter actually passed into the helper, matching the test’s intent and eliminating the race-related flake.
Changed components
test/functional/p2p_private_broadcast.pyInspect captured patch +1 / −1
diff --git a/test/functional/p2p_private_broadcast.py b/test/functional/p2p_private_broadcast.py
index 9a1a7991..b81b5aa4 100755
--- a/test/functional/p2p_private_broadcast.py
+++ b/test/functional/p2p_private_broadcast.py
@@ -310,7 +310,7 @@ class P2PPrivateBroadcast(BitcoinTestFramework):
peers = pending[0]["peers"]
assert len(peers) >= NUM_PRIVATE_BROADCAST_PER_TX
assert all("address" in p and "sent" in p for p in peers)
- assert_greater_than_or_equal(sum(1 for p in peers if "received" in p), NUM_PRIVATE_BROADCAST_PER_TX)
+ assert_greater_than_or_equal(sum(1 for p in peers if "received" in p), broadcasts_to_expect)
def run_test(self):
tx_originator = self.nodes[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.