|
19 | 19 |
|
20 | 20 | - TODO: Valid hash but invalid snapshot file (bad coin height or
|
21 | 21 | bad other serialization)
|
22 |
| -- TODO: Valid snapshot file, but referencing an unknown block |
23 | 22 | - TODO: Valid snapshot file, but referencing a snapshot block that turns out to be
|
24 | 23 | invalid, or has an invalid parent
|
25 | 24 | - TODO: Valid snapshot file and snapshot block, but the block is not on the
|
@@ -71,12 +70,14 @@ def test_invalid_snapshot_scenarios(self, valid_snapshot_path):
|
71 | 70 | bad_snapshot_path = valid_snapshot_path + '.mod'
|
72 | 71 |
|
73 | 72 | self.log.info(" - snapshot file refering to a block that is not in the assumeutxo parameters")
|
74 |
| - bad_snapshot_block_hash = self.nodes[0].getblockhash(SNAPSHOT_BASE_HEIGHT - 1) |
75 |
| - with open(bad_snapshot_path, 'wb') as f: |
76 |
| - # block hash of the snapshot base is stored right at the start (first 32 bytes) |
77 |
| - f.write(bytes.fromhex(bad_snapshot_block_hash)[::-1] + valid_snapshot_contents[32:]) |
78 |
| - error_details = f"assumeutxo block hash in snapshot metadata not recognized ({bad_snapshot_block_hash})" |
79 |
| - assert_raises_rpc_error(-32603, f"Unable to load UTXO snapshot, {error_details}", self.nodes[1].loadtxoutset, bad_snapshot_path) |
| 73 | + prev_block_hash = self.nodes[0].getblockhash(SNAPSHOT_BASE_HEIGHT - 1) |
| 74 | + bogus_block_hash = "0" * 64 # Represents any unknown block hash |
| 75 | + for bad_block_hash in [bogus_block_hash, prev_block_hash]: |
| 76 | + with open(bad_snapshot_path, 'wb') as f: |
| 77 | + # block hash of the snapshot base is stored right at the start (first 32 bytes) |
| 78 | + f.write(bytes.fromhex(bad_block_hash)[::-1] + valid_snapshot_contents[32:]) |
| 79 | + error_details = f"assumeutxo block hash in snapshot metadata not recognized ({bad_block_hash})" |
| 80 | + assert_raises_rpc_error(-32603, f"Unable to load UTXO snapshot, {error_details}", self.nodes[1].loadtxoutset, bad_snapshot_path) |
80 | 81 |
|
81 | 82 | self.log.info(" - snapshot file with wrong number of coins")
|
82 | 83 | valid_num_coins = int.from_bytes(valid_snapshot_contents[32:32 + 8], "little")
|
|
0 commit comments