diff options
author | Fabian Jahr <fjahr@protonmail.com> | 2023-10-17 16:57:07 +0200 |
---|---|---|
committer | Fabian Jahr <fjahr@protonmail.com> | 2023-10-17 17:12:29 +0200 |
commit | 621db2f00486d8fd6f06dca91c1b95ce61f64bc4 (patch) | |
tree | 334bd09a18f6a7779876ab4470b6c30f5564c823 /test | |
parent | 738ef44abb6895dad016d8f32f7d7fa1c251b354 (diff) |
test: assumeutxo file with unknown block hash
Diffstat (limited to 'test')
-rwxr-xr-x | test/functional/feature_assumeutxo.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py index 376e35da3b..3cb346c158 100755 --- a/test/functional/feature_assumeutxo.py +++ b/test/functional/feature_assumeutxo.py @@ -20,7 +20,6 @@ Interesting test cases could be loading an assumeutxo snapshot file with: - 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 @@ -73,12 +72,14 @@ class AssumeutxoTest(BitcoinTestFramework): bad_snapshot_path = valid_snapshot_path + '.mod' self.log.info(" - snapshot file refering to a block that is not in the assumeutxo parameters") - bad_snapshot_block_hash = self.nodes[0].getblockhash(SNAPSHOT_BASE_HEIGHT - 1) - with open(bad_snapshot_path, 'wb') as f: - # block hash of the snapshot base is stored right at the start (first 32 bytes) - f.write(bytes.fromhex(bad_snapshot_block_hash)[::-1] + valid_snapshot_contents[32:]) - 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) + prev_block_hash = self.nodes[0].getblockhash(SNAPSHOT_BASE_HEIGHT - 1) + bogus_block_hash = "0" * 64 # Represents any unknown block hash + for bad_block_hash in [bogus_block_hash, prev_block_hash]: + with open(bad_snapshot_path, 'wb') as f: + # block hash of the snapshot base is stored right at the start (first 32 bytes) + f.write(bytes.fromhex(bad_block_hash)[::-1] + valid_snapshot_contents[32:]) + error_details = f"assumeutxo block hash in snapshot metadata not recognized ({bad_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] |