From f731bc214ac321d0324604508af9cece4f0db9ca Mon Sep 17 00:00:00 2001 From: Fabian Jahr Date: Tue, 16 Jul 2024 18:35:56 +0100 Subject: [PATCH] test: Add test for outdated coinstats index version --- test/functional/data/coinstatsindex_v0/CURRENT | 1 + test/functional/data/coinstatsindex_v0/LOCK | 0 .../data/coinstatsindex_v0/MANIFEST-000002 | Bin 0 -> 50 bytes test/functional/feature_coinstatsindex.py | 16 ++++++++++++++++ 4 files changed, 17 insertions(+) create mode 100644 test/functional/data/coinstatsindex_v0/CURRENT create mode 100644 test/functional/data/coinstatsindex_v0/LOCK create mode 100644 test/functional/data/coinstatsindex_v0/MANIFEST-000002 diff --git a/test/functional/data/coinstatsindex_v0/CURRENT b/test/functional/data/coinstatsindex_v0/CURRENT new file mode 100644 index 00000000000000..1a84852211ef37 --- /dev/null +++ b/test/functional/data/coinstatsindex_v0/CURRENT @@ -0,0 +1 @@ +MANIFEST-000002 diff --git a/test/functional/data/coinstatsindex_v0/LOCK b/test/functional/data/coinstatsindex_v0/LOCK new file mode 100644 index 00000000000000..e69de29bb2d1d6 diff --git a/test/functional/data/coinstatsindex_v0/MANIFEST-000002 b/test/functional/data/coinstatsindex_v0/MANIFEST-000002 new file mode 100644 index 0000000000000000000000000000000000000000..bbbc585686bcbcc33686059c69d80b7b4e1291cd GIT binary patch literal 50 zcmWIhx#Ncn10$nUPHI_dPD+xVQ)NkNd1i5{bAE0?Vo_pAe$kRS-TOEg7@3$k8JJmE F7y#sj5K{mE literal 0 HcmV?d00001 diff --git a/test/functional/feature_coinstatsindex.py b/test/functional/feature_coinstatsindex.py index 479c5711a222f0..987c736e5f5af3 100755 --- a/test/functional/feature_coinstatsindex.py +++ b/test/functional/feature_coinstatsindex.py @@ -10,6 +10,9 @@ """ from decimal import Decimal +import os +from pathlib import Path +import shutil from test_framework.blocktools import ( COINBASE_MATURITY, @@ -53,6 +56,7 @@ def run_test(self): self._test_reorg_index() self._test_index_rejects_hash_serialized() self._test_init_index_after_reorg() + self._test_outdated_index_version() def block_sanity_check(self, block_info): block_subsidy = 50 @@ -322,6 +326,18 @@ def _test_init_index_after_reorg(self): res1 = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=None, use_index=True) assert_equal(res["muhash"], res1["muhash"]) + def _test_outdated_index_version(self): + self.log.info("Test a node doesn't start with an outdated index version") + index_node = self.nodes[1] + index_db = index_node.chain_path / 'indexes' / 'coinstats' / 'db' + shutil.rmtree(index_db) + v0_index_db = Path(os.path.dirname(os.path.realpath(__file__))) / 'data' / 'coinstatsindex_v0' + shutil.copytree(v0_index_db, index_db) + self.stop_node(1) + msg = "[error] coinstatsindex version mismatch: expected 1 but 0 was found. In order to rebuild the index, remove the indexes/coinstats directory in your datadir" + with index_node.assert_debug_log(expected_msgs=[msg]): + index_node.assert_start_raises_init_error(extra_args=["-coinstatsindex"]) + if __name__ == '__main__': CoinStatsIndexTest().main()