Skip to content

Commit

Permalink
test: assumeutxo file with unknown block hash
Browse files Browse the repository at this point in the history
  • Loading branch information
fjahr committed Oct 17, 2023
1 parent 738ef44 commit 5958f7b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/functional/feature_assumeutxo.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
- TODO: An invalid hash
- TODO: Valid hash but invalid snapshot file (bad coin height or truncated file or
bad other serialization)
- TODO: Valid snapshot file, but referencing an unknown block
- TODO: Valid snapshot file, but referencing a snapshot block that turns out to be
invalid, or has an invalid parent
- TODO: Valid snapshot file and snapshot block, but the block is not on the
Expand Down Expand Up @@ -80,6 +79,14 @@ def test_invalid_snapshot_scenarios(self, valid_snapshot_path):
error_details = f"assumeutxo block hash in snapshot metadata not recognized ({bad_snapshot_block_hash})"
assert_raises_rpc_error(-32603, f"Unable to load UTXO snapshot, {error_details}", self.nodes[1].loadtxoutset, bad_snapshot_path)

self.log.info(" - snapshot file refering to a block that is unknown")
# Represents any unknown block hash
bogus_block_hash = "0" * 64
with open(bad_snapshot_path, 'wb') as f:
f.write(bytes.fromhex(bogus_block_hash)[::-1] + valid_snapshot_contents[32:])
error_details = f"assumeutxo block hash in snapshot metadata not recognized ({bogus_block_hash})"
assert_raises_rpc_error(-32603, f"Unable to load UTXO snapshot, {error_details}", self.nodes[1].loadtxoutset, bad_snapshot_path)

self.log.info(" - snapshot file with wrong number of coins")
valid_num_coins = struct.unpack("<I", valid_snapshot_contents[32:32 + 4])[0]
for off in [-1, +1]:
Expand Down

0 comments on commit 5958f7b

Please sign in to comment.