From df6dc2aaaeffc664006b86ee8c8797dc484ec40e Mon Sep 17 00:00:00 2001 From: Hernan Marino Date: Mon, 12 Feb 2024 22:24:57 -0300 Subject: [PATCH] test: Assumeutxo: snapshots with less work should not be loaded --- test/functional/feature_assumeutxo.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py index 0d6c92c9fad..b15130dd8f0 100755 --- a/test/functional/feature_assumeutxo.py +++ b/test/functional/feature_assumeutxo.py @@ -161,6 +161,14 @@ class AssumeutxoTest(BitcoinTestFramework): path = node.datadir_path / node.chain / "invalid" / "path" assert_raises_rpc_error(-8, "Couldn't open file {} for reading.".format(path), node.loadtxoutset, path) + def test_snapshot_with_less_work(self, dump_output_path): + self.log.info("Test bitcoind should fail when snapshot has less accumulated work than this node.") + node = self.nodes[0] + assert_equal(node.getblockcount(), FINAL_HEIGHT) + with node.assert_debug_log(expected_msgs=["[snapshot] activation failed - work does not exceed active chainstate"]): + assert_raises_rpc_error(-32603, "Unable to load UTXO snapshot", node.loadtxoutset, dump_output_path) + self.restart_node(0, extra_args=self.extra_args[0]) + def run_test(self): """ Bring up two (disconnected) nodes, mine some new blocks on the first, @@ -242,6 +250,7 @@ class AssumeutxoTest(BitcoinTestFramework): assert_equal(n0.getblockchaininfo()["blocks"], FINAL_HEIGHT) + self.test_snapshot_with_less_work(dump_output['path']) self.test_invalid_mempool_state(dump_output['path']) self.test_invalid_snapshot_scenarios(dump_output['path']) self.test_invalid_chainstate_scenarios()