test: add background validation test for getblockchaininfo
What changed, and why it matters
This commit only adds a new automated test that checks what information the getblockchaininfo RPC returns about a background validation process. It does not change any production code, network behavior, or wallet logic, so it cannot introduce a security vulnerability or fix one.
No security action needed; review as ordinary test coverage improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff appends a test case to test/functional/feature_assumeutxo.py. It calls getblockchaininfo on a node that has loaded a UTXO snapshot and verifies that the backgroundvalidation sub-object contains the expected keys (snapshotheight, blocks, bestblockhash, mediantime, chainwork, verificationprogress) and that their values match independently computed results. No C++/Python production code is modified.
Changed components
test/functional/feature_assumeutxo.pyInspect captured patch +24 / −0
diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py
index 7420dfe0..f7f0d279 100755
--- a/test/functional/feature_assumeutxo.py
+++ b/test/functional/feature_assumeutxo.py
@@ -541,6 +541,30 @@ class AssumeutxoTest(BitcoinTestFramework):
assert_equal(utxo_info['height'], SNAPSHOT_BASE_HEIGHT)
assert_equal(utxo_info['bestblock'], snapshot_hash)
+ self.log.info("Check that getblockchaininfo returns information about the background validation process")
+ expected_keys = [
+ "snapshotheight",
+ "blocks",
+ "bestblockhash",
+ "mediantime",
+ "chainwork",
+ "verificationprogress"
+ ]
+ res = n1.getblockchaininfo()
+ assert "backgroundvalidation" in res.keys()
+ bv_res = res["backgroundvalidation"]
+ assert_equal(sorted(expected_keys), sorted(bv_res.keys()))
+ assert_equal(bv_res["snapshotheight"], SNAPSHOT_BASE_HEIGHT)
+ assert_equal(bv_res["blocks"], START_HEIGHT)
+ assert_equal(bv_res["bestblockhash"], n1.getblockhash(START_HEIGHT))
+ block = n1.getblockheader(bv_res["bestblockhash"])
+ assert_equal(bv_res["mediantime"], block["mediantime"])
+ assert_equal(bv_res["chainwork"], block["chainwork"])
+ background_tx_count = n1.getchaintxstats(blockhash=bv_res["bestblockhash"])["txcount"]
+ snapshot_tx_count = n1.getchaintxstats(blockhash=snapshot_hash)["txcount"]
+ expected_verification_progress = background_tx_count / snapshot_tx_count
+ assert_approx(bv_res["verificationprogress"], expected_verification_progress, vspan=0.01)
+
# find coinbase output at snapshot height on node0 and scan for it on node1,
# where the block is not available, but the snapshot was loaded successfully
coinbase_tx = n0.getblock(snapshot_hash, verbosity=2)['tx'][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.