test: Verify peer usage after assumeutxo validation completes
What changed, and why it matters
This commit only adds a new automated test to Bitcoin Core. It does not change any production code, network rules, or wallet behavior. The test verifies that a node using the assumeutxo snapshot feature can later switch to a different chain with more proof-of-work once background validation finishes. There is no security vulnerability introduced here.
No action required; this is a benign test-only change. Reviewers may optionally confirm the preceding commit contains the actual fix referenced in the test message.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds a single test method, test_sync_to_most_work_chain_after_background_validation(), to test/functional/feature_assumeutxo.py and calls it from the main test routine. The test creates a fork one block before the snapshot base height, mines enough blocks to make the fork have more cumulative chainwork, and checks that the snapshot node reorgs to that most-work chain. It is purely test coverage and references a fix in the previous commit; no C++/Python node logic is modified.
Changed components
test/functional/feature_assumeutxo.pyInspect captured patch +25 / −0
diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py
index 20ebd823..7420dfe0 100755
--- a/test/functional/feature_assumeutxo.py
+++ b/test/functional/feature_assumeutxo.py
@@ -347,6 +347,29 @@ class AssumeutxoTest(BitcoinTestFramework):
assert 'NETWORK' in ibd_node.getpeerinfo()[0]['servicesnames']
self.sync_blocks(nodes=(ibd_node, snapshot_node))
+ def test_sync_to_most_work_chain_after_background_validation(self):
+ """
+ After background validation completes, node should be able
+ to download and process blocks from peers without the snapshot block in their chain.
+ """
+ self.log.info("Testing sync to the most-work chain without the snapshot block after background validation")
+
+ forking_node = self.nodes[0]
+ snapshot_node = self.nodes[2] # Has already completed background validation
+
+ self.log.info("Forking node switches to an alternative chain that forks one block before the snapshot block")
+ fork_point = SNAPSHOT_BASE_HEIGHT - 1
+ forking_node_old_height = forking_node.getblockcount()
+ forking_node_old_chainwork = int(forking_node.getblockchaininfo()['chainwork'], 16)
+ forking_node.invalidateblock(forking_node.getblockhash(fork_point + 1))
+
+ self.log.info("Mine one more block than original chain to make the new chain have most work")
+ self.generate(forking_node, nblocks=(forking_node_old_height - fork_point) + 1, sync_fun=self.no_op)
+ assert int(forking_node.getblockchaininfo()['chainwork'], 16) > forking_node_old_chainwork
+
+ self.log.info("Snapshot node should reorg to the most-work chain without the snapshot block")
+ self.sync_blocks(nodes=(snapshot_node, forking_node))
+
def assert_only_network_limited_service(self, node):
node_services = node.getnetworkinfo()['localservicesnames']
assert 'NETWORK' not in node_services
@@ -775,6 +798,8 @@ class AssumeutxoTest(BitcoinTestFramework):
# The following test cleans node2 and node3 chain directories.
self.test_sync_from_assumeutxo_node(snapshot=dump_output)
+ self.test_sync_to_most_work_chain_after_background_validation()
+
@dataclass
class Block:
hash: str
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.