Skip to content

Commit

Permalink
test: Add loadtxoutset test with tip on snapshot block
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fjahr committed Jul 10, 2024
1 parent c8b3ebd commit 3dc175e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/functional/feature_assumeutxo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
Interesting starting states could be loading a snapshot when the current chain tip is:
- TODO: Not an ancestor of the snapshot block but has less work
- TODO: The snapshot block
- TODO: Not an ancestor or a descendant of the snapshot block and has more work
"""
Expand Down Expand Up @@ -197,7 +196,6 @@ def test_invalid_file_path(self):
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)

Expand Down Expand Up @@ -263,6 +261,11 @@ def run_test(self):
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'])

Expand Down

0 comments on commit 3dc175e

Please sign in to comment.