test: Add coinstatsindex compatibility test
What changed, and why it matters
This commit only adds a new automated test that checks the coinstatsindex feature works consistently across different Bitcoin Core versions. It does not change any production code, so it cannot directly introduce a security vulnerability or fix one.
No security action required; review as normal test code.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit introduces a new functional test, feature_coinstatsindex_compatibility.py, and registers it in test_runner.py. The test verifies that gettxoutsetinfo(‘muhash’) returns identical results between a current node and a legacy v28.2 node, and that a current node can upgrade an older coinstatsindex data directory while logging a deprecation warning. No C++/Python production logic is modified.
Changed components
test/functional/feature_coinstatsindex_compatibility.pytest/functional/test_runner.pyInspect captured patch +65 / −0
diff --git a/test/functional/feature_coinstatsindex_compatibility.py b/test/functional/feature_coinstatsindex_compatibility.py
new file mode 100755
index 00000000..357700a7
--- /dev/null
+++ b/test/functional/feature_coinstatsindex_compatibility.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python3
+# Copyright (c) 2025 The Bitcoin Core developers
+# Distributed under the MIT software license, see the accompanying
+# file COPYING or http://www.opensource.org/licenses/mit-license.php.
+"""Test coinstatsindex across node versions.
+
+This test may be removed some time after v29 has reached end of life.
+"""
+
+import shutil
+
+from test_framework.test_framework import BitcoinTestFramework
+from test_framework.util import assert_equal
+
+
+class CoinStatsIndexTest(BitcoinTestFramework):
+ def set_test_params(self):
+ self.num_nodes = 2
+ self.supports_cli = False
+ self.extra_args = [["-coinstatsindex"],["-coinstatsindex"]]
+
+ def skip_test_if_missing_module(self):
+ self.skip_if_no_previous_releases()
+
+ def setup_nodes(self):
+ self.add_nodes(
+ self.num_nodes,
+ extra_args=self.extra_args,
+ versions=[
+ None,
+ 280200,
+ ],
+ )
+ self.start_nodes()
+
+ def run_test(self):
+ self._test_coin_stats_index_compatibility()
+
+ def _test_coin_stats_index_compatibility(self):
+ node = self.nodes[0]
+ legacy_node = self.nodes[1]
+ for n in self.nodes:
+ self.wait_until(lambda: n.getindexinfo()['coinstatsindex']['synced'] is True)
+
+ self.log.info("Test that gettxoutsetinfo() output is consistent between the different index versions")
+ res0 = node.gettxoutsetinfo('muhash')
+ res1 = legacy_node.gettxoutsetinfo('muhash')
+ assert_equal(res1, res0)
+
+ self.log.info("Test that gettxoutsetinfo() output is consistent for the new index running on a datadir with the old version")
+ self.stop_nodes()
+ shutil.rmtree(node.chain_path / "indexes" / "coinstatsindex")
+ shutil.copytree(legacy_node.chain_path / "indexes" / "coinstats", node.chain_path / "indexes" / "coinstats")
+ old_version_path = node.chain_path / "indexes" / "coinstats"
+ msg = f'[warning] Old version of coinstatsindex found at {old_version_path}. This folder can be safely deleted unless you plan to downgrade your node to version 29 or lower.'
+ with node.assert_debug_log(expected_msgs=[msg]):
+ self.start_node(0, ['-coinstatsindex'])
+ self.wait_until(lambda: node.getindexinfo()['coinstatsindex']['synced'] is True)
+ res2 = node.gettxoutsetinfo('muhash')
+ assert_equal(res2, res0)
+
+
+if __name__ == '__main__':
+ CoinStatsIndexTest(__file__).main()
diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py
index f2e514a7..94965618 100755
--- a/test/functional/test_runner.py
+++ b/test/functional/test_runner.py
@@ -342,6 +342,7 @@ BASE_SCRIPTS = [
'feature_anchors.py',
'mempool_datacarrier.py',
'feature_coinstatsindex.py',
+ 'feature_coinstatsindex_compatibility.py',
'wallet_orphanedreward.py',
'wallet_timelock.py',
'p2p_permissions.py',
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.