Skip to content

Commit eefcec0

Browse files
achow101PastaPastaPasta
authored andcommitted
Merge bitcoin#30403: test, assumeutxo: Remove resolved todo comments and add new test
d63ef73 test: Add loadtxoutset test with tip on snapshot block (Fabian Jahr) c2f86d4 test: Remove already resolved assumeutxo todo comments (Fabian Jahr) Pull request description: The first commit removes three Todos that have been addressed previously (see commit message for details). The second message resolves another todo by adding the missing test case. This is a special case of "the tip has more work than the snapshot" where the tip is the same block as the snapshot base block. Related to bitcoin#28648. ACKs for top commit: jrakibi: ACK [d63ef73](bitcoin@d63ef73) achow101: ACK d63ef73 maflcko: ACK d63ef73 alfonsoromanz: Re ACK d63ef73 Tree-SHA512: 8d5a25fc0b26531db3a9740132694138f2103b7b42eeb1d4a64095bfc901c1372e23601c0855c7def84c8a4e185d10611e4e830c4e479f1b663ae6ed53abb130
1 parent 7b8f749 commit eefcec0

1 file changed

Lines changed: 6 additions & 17 deletions

File tree

test/functional/feature_assumeutxo.py

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,6 @@
88
99
The assumeutxo value generated and used here is committed to in
1010
`CRegTestParams::m_assumeutxo_data` in `src/chainparams.cpp`.
11-
12-
## Possible test improvements
13-
14-
Interesting test cases could be loading an assumeutxo snapshot file with:
15-
16-
- TODO: Valid hash but invalid snapshot file (bad coin height or
17-
bad other serialization)
18-
- TODO: Valid snapshot file, but referencing a snapshot block that turns out to be
19-
invalid, or has an invalid parent
20-
21-
Interesting starting states could be loading a snapshot when the current chain tip is:
22-
23-
- TODO: An ancestor of snapshot block
24-
- TODO: The snapshot block
25-
- TODO: A descendant of the snapshot block
26-
2711
"""
2812
from dataclasses import dataclass
2913
from decimal import Decimal
@@ -170,7 +154,6 @@ def test_invalid_mempool_state(self, dump_output_path):
170154
def test_snapshot_with_less_work(self, dump_output_path):
171155
self.log.info("Test dashd should fail when snapshot has less accumulated work than this node.")
172156
node = self.nodes[0]
173-
assert_equal(node.getblockcount(), FINAL_HEIGHT)
174157
with node.assert_debug_log(expected_msgs=["[snapshot] activation failed - work does not exceed active chainstate"]):
175158
assert_raises_rpc_error(-32603, "Unable to load UTXO snapshot", node.loadtxoutset, dump_output_path)
176159

@@ -320,6 +303,10 @@ def run_test(self):
320303
self.log.info(f"Creating a UTXO snapshot at height {SNAPSHOT_BASE_HEIGHT}")
321304
dump_output = n0.dumptxoutset('utxos.dat', "latest")
322305

306+
self.log.info("Test loading snapshot when the node tip is on the same block as the snapshot")
307+
assert_equal(n0.getblockcount(), SNAPSHOT_BASE_HEIGHT)
308+
assert_equal(n0.getblockchaininfo()["blocks"], SNAPSHOT_BASE_HEIGHT)
309+
self.test_snapshot_with_less_work(dump_output['path'])
323310
assert_equal(n0.getblockchaininfo()["blocks"], SNAPSHOT_BASE_HEIGHT)
324311

325312
def check_dump_output(output):
@@ -381,6 +368,8 @@ def check_dump_output(output):
381368
self.test_snapshot_not_on_most_work_chain(dump_output['path'])
382369

383370
self.log.info(f"Loading snapshot into second node from {dump_output['path']}")
371+
# This node's tip is on an ancestor block of the snapshot, which should
372+
# be the normal case
384373
loaded = n1.loadtxoutset(dump_output['path'])
385374
assert_equal(loaded['coins_loaded'], SNAPSHOT_BASE_HEIGHT)
386375
assert_equal(loaded['base_height'], SNAPSHOT_BASE_HEIGHT)

0 commit comments

Comments
 (0)