|
8 | 8 |
|
9 | 9 | The assumeutxo value generated and used here is committed to in
|
10 | 10 | `CRegTestParams::m_assumeutxo_data` in `src/kernel/chainparams.cpp`.
|
11 |
| -
|
12 |
| -## Possible test improvements |
13 |
| -
|
14 |
| -Interesting test cases could be loading an assumeutxo snapshot file with: |
15 |
| -
|
16 |
| -- TODO: Valid snapshot file, but referencing a snapshot block that turns out to be |
17 |
| - invalid, or has an invalid parent |
18 |
| -
|
19 |
| -Interesting starting states could be loading a snapshot when the current chain tip is: |
20 |
| -
|
21 |
| -- TODO: An ancestor of snapshot block |
22 |
| -- TODO: The snapshot block |
23 |
| -- TODO: A descendant of the snapshot block |
24 |
| -
|
25 | 11 | """
|
26 | 12 | from shutil import rmtree
|
27 | 13 |
|
@@ -202,7 +188,6 @@ def test_invalid_file_path(self):
|
202 | 188 | def test_snapshot_with_less_work(self, dump_output_path):
|
203 | 189 | self.log.info("Test bitcoind should fail when snapshot has less accumulated work than this node.")
|
204 | 190 | node = self.nodes[0]
|
205 |
| - assert_equal(node.getblockcount(), FINAL_HEIGHT) |
206 | 191 | with node.assert_debug_log(expected_msgs=["[snapshot] activation failed - work does not exceed active chainstate"]):
|
207 | 192 | assert_raises_rpc_error(-32603, "Unable to load UTXO snapshot", node.loadtxoutset, dump_output_path)
|
208 | 193 |
|
@@ -316,6 +301,11 @@ def run_test(self):
|
316 | 301 | self.log.info(f"Creating a UTXO snapshot at height {SNAPSHOT_BASE_HEIGHT}")
|
317 | 302 | dump_output = n0.dumptxoutset('utxos.dat')
|
318 | 303 |
|
| 304 | + self.log.info("Test loading snapshot when the node tip is on the same block as the snapshot") |
| 305 | + assert_equal(n0.getblockcount(), SNAPSHOT_BASE_HEIGHT) |
| 306 | + assert_equal(n0.getblockchaininfo()["blocks"], SNAPSHOT_BASE_HEIGHT) |
| 307 | + self.test_snapshot_with_less_work(dump_output['path']) |
| 308 | + |
319 | 309 | self.log.info("Test loading snapshot when headers are not synced")
|
320 | 310 | self.test_headers_not_synced(dump_output['path'])
|
321 | 311 |
|
@@ -358,6 +348,8 @@ def run_test(self):
|
358 | 348 | self.test_snapshot_not_on_most_work_chain(dump_output['path'])
|
359 | 349 |
|
360 | 350 | self.log.info(f"Loading snapshot into second node from {dump_output['path']}")
|
| 351 | + # This node's tip is on an ancestor block of the snapshot, which should |
| 352 | + # be the normal case |
361 | 353 | loaded = n1.loadtxoutset(dump_output['path'])
|
362 | 354 | assert_equal(loaded['coins_loaded'], SNAPSHOT_BASE_HEIGHT)
|
363 | 355 | assert_equal(loaded['base_height'], SNAPSHOT_BASE_HEIGHT)
|
|
0 commit comments