test: Ensure invalid block was processed before checking debug.log
What changed, and why it matters
This is a fix to a flaky automated test, not a security fix in the Bitcoin software itself. The test was sometimes checking the debug log too quickly, before the program had finished evaluating a deliberately-invalid block. The patch makes the test wait until the block is confirmed as invalid before checking the log. It does not change how Bitcoin validates blocks or affect real users.
No security action required. This is a test-only reliability improvement. Reviewers can treat it as a normal CI/test fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
In test/functional/feature_assumevalid.py, the test asserts that a modified block 102 is rejected. The assertion on debug.log could race with asynchronous block validation, causing intermittent CI failures. The patch adds a wait_until that polls getchaintips() until the target block’s status becomes ‘invalid’, ensuring validation has completed before the log assertion runs. No consensus, networking, or validation code is modified.
Changed components
test/functional/feature_assumevalid.pyInspect captured patch +1 / −0
diff --git a/test/functional/feature_assumevalid.py b/test/functional/feature_assumevalid.py
index ed2bff63..2ee23c6e 100755
--- a/test/functional/feature_assumevalid.py
+++ b/test/functional/feature_assumevalid.py
@@ -164,6 +164,7 @@ class AssumeValidTest(BitcoinTestFramework):
self.send_blocks_until_disconnected(p2p0)
self.wait_until(lambda: self.nodes[0].getblockcount() >= COINBASE_MATURITY + 1)
assert_equal(self.nodes[0].getblockcount(), COINBASE_MATURITY + 1)
+ self.wait_until(lambda: next(filter(lambda x: x["hash"] == self.blocks[-1].hash_hex, self.nodes[0].getchaintips()))["status"] == "invalid")
# nodes[1]
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.