What changed, and why it matters
This commit only adds a new automated test for the dumptxoutset RPC command. It checks that when the blockchain has a temporary fork, the snapshot is created at the requested rollback height rather than accidentally using the forked chain tip. There is no change to production code, no bug fix, and no security patch.
No action needed; this is a benign test-only addition.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff adds test_dumptxoutset_with_fork() to test/functional/rpc_dumptxoutset.py. The test invalidates a block to create a two-block side chain, then calls dumptxoutset with rollback target_height and asserts base_height/base_hash match the original main-chain block. It is purely test coverage for existing behavior.
Changed components
test/functional/rpc_dumptxoutset.pyInspect captured patch +27 / −0
diff --git a/test/functional/rpc_dumptxoutset.py b/test/functional/rpc_dumptxoutset.py
index 90f635ce..0f68aeb9 100755
--- a/test/functional/rpc_dumptxoutset.py
+++ b/test/functional/rpc_dumptxoutset.py
@@ -19,6 +19,30 @@ class DumptxoutsetTest(BitcoinTestFramework):
self.setup_clean_chain = True
self.num_nodes = 1
+ def test_dumptxoutset_with_fork(self):
+ node = self.nodes[0]
+ tip = node.getbestblockhash()
+ target_height = node.getblockcount() - 10
+ target_hash = node.getblockhash(target_height)
+
+ # Create a fork of two blocks at the target height
+ invalid_block = node.getblockhash(target_height + 1)
+ node.invalidateblock(invalid_block)
+ # Reset mocktime to not regenerate the same blockhash
+ node.setmocktime(0)
+ self.generate(node, 2)
+
+ # Move back on to actual main chain
+ node.reconsiderblock(invalid_block)
+ self.wait_until(lambda: node.getbestblockhash() == tip)
+
+ # Use dumptxoutset at the forked height
+ out = node.dumptxoutset("txoutset_fork.dat", "rollback", {"rollback": target_height})
+
+ # Verify the snapshot was created at the target height and not the fork tip
+ assert_equal(out['base_height'], target_height)
+ assert_equal(out['base_hash'], target_hash)
+
def run_test(self):
"""Test a trivial usage of the dumptxoutset RPC command."""
node = self.nodes[0]
@@ -60,6 +84,9 @@ class DumptxoutsetTest(BitcoinTestFramework):
assert_raises_rpc_error(
-8, 'Invalid snapshot type "bogus" specified. Please specify "rollback" or "latest"', node.dumptxoutset, 'utxos.dat', "bogus")
+ self.log.info("Testing dumptxoutset with chain fork at target height")
+ self.test_dumptxoutset_with_fork()
+
if __name__ == '__main__':
DumptxoutsetTest(__file__).main()
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.