From d63ef738001fb69ce04134cc8645dcd1e1cbccd1 Mon Sep 17 00:00:00 2001 From: Fabian Jahr Date: Mon, 8 Jul 2024 12:12:33 +0100 Subject: [PATCH] test: Add loadtxoutset test with tip on snapshot block Also pulls out the guarding assert and calls it explicitly before the test function is called. This is already done before the existing call of the test function so it was not needed there. --- test/functional/feature_assumeutxo.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py index 8ef92b9b6f1..868017ab854 100755 --- a/test/functional/feature_assumeutxo.py +++ b/test/functional/feature_assumeutxo.py @@ -8,13 +8,6 @@ to a hash that has been compiled into bitcoind. The assumeutxo value generated and used here is committed to in `CRegTestParams::m_assumeutxo_data` in `src/kernel/chainparams.cpp`. - -## Possible test improvements - -Interesting starting states could be loading a snapshot when the current chain tip is: - -- TODO: The snapshot block - """ from shutil import rmtree @@ -195,7 +188,6 @@ class AssumeutxoTest(BitcoinTestFramework): 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) @@ -309,6 +301,11 @@ class AssumeutxoTest(BitcoinTestFramework): self.log.info(f"Creating a UTXO snapshot at height {SNAPSHOT_BASE_HEIGHT}") dump_output = n0.dumptxoutset('utxos.dat') + self.log.info("Test loading snapshot when the node tip is on the same block as the snapshot") + assert_equal(n0.getblockcount(), SNAPSHOT_BASE_HEIGHT) + assert_equal(n0.getblockchaininfo()["blocks"], SNAPSHOT_BASE_HEIGHT) + self.test_snapshot_with_less_work(dump_output['path']) + self.log.info("Test loading snapshot when headers are not synced") self.test_headers_not_synced(dump_output['path'])