From c2f86d4bcba290c33ed99383cc76380bb15ba384 Mon Sep 17 00:00:00 2001 From: Fabian Jahr Date: Sat, 6 Jul 2024 18:09:37 +0200 Subject: [PATCH 1/2] test: Remove already resolved assumeutxo todo comments - "Valid snapshot file, but referencing a snapshot block that turns out to be invalid, or has an invalid parent" has been addressed in #30267 - "An ancestor of snapshot block" - If chain tip refers to blocks in this context then any successful load is addressing this because if we have synced past the snapshot base block we fail because we don't need assumeutxo anymore. And if this is about headers then this is the `test_headers_not_synced()` case. - "A descendant of the snapshot block" - If this refers to blocks the `test_snapshot_with_less_work()` addressed this and if it is just headers in this case again it would be represented in all of the successful loads in the test. Co-authored-by: Alfonso Roman Zubeldia --- test/functional/feature_assumeutxo.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py index 17c1554cdef..8ef92b9b6f1 100755 --- a/test/functional/feature_assumeutxo.py +++ b/test/functional/feature_assumeutxo.py @@ -11,16 +11,9 @@ The assumeutxo value generated and used here is committed to in ## Possible test improvements -Interesting test cases could be loading an assumeutxo snapshot file with: - -- TODO: Valid snapshot file, but referencing a snapshot block that turns out to be - invalid, or has an invalid parent - Interesting starting states could be loading a snapshot when the current chain tip is: -- TODO: An ancestor of snapshot block - TODO: The snapshot block -- TODO: A descendant of the snapshot block """ from shutil import rmtree @@ -358,6 +351,8 @@ class AssumeutxoTest(BitcoinTestFramework): self.test_snapshot_not_on_most_work_chain(dump_output['path']) self.log.info(f"Loading snapshot into second node from {dump_output['path']}") + # This node's tip is on an ancestor block of the snapshot, which should + # be the normal case loaded = n1.loadtxoutset(dump_output['path']) assert_equal(loaded['coins_loaded'], SNAPSHOT_BASE_HEIGHT) assert_equal(loaded['base_height'], SNAPSHOT_BASE_HEIGHT) From d63ef738001fb69ce04134cc8645dcd1e1cbccd1 Mon Sep 17 00:00:00 2001 From: Fabian Jahr Date: Mon, 8 Jul 2024 12:12:33 +0100 Subject: [PATCH 2/2] 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'])