test, assumeutxo: add coverage for loadtxoutset EOF error

Add a test to cover scenarios where an EOF error is raised during
the reading of invalid snapshot metadata regarding its small size
(40 bytes required) or a corrupted file with an invalid format.
This commit is contained in:
pablomartin4btc 2024-01-17 15:04:21 -03:00
parent 40e45a7635
commit 521de52c75
1 changed files with 7 additions and 0 deletions

View File

@ -114,6 +114,13 @@ class AssumeutxoTest(BitcoinTestFramework):
f.write(valid_snapshot_contents[(32 + 8 + offset + len(content)):])
expected_error(log_msg=f"[snapshot] bad snapshot content hash: expected a4bf3407ccb2cc0145c49ebba8fa91199f8a3903daf0883875941497d2493c27, got {wrong_hash}")
self.log.info(" - snapshot file with invalid size, too small")
with open(bad_snapshot_path, "wb") as f:
f.write(b'z' * 1)
expected_error_msg = (f", couldn't read snapshot metadata from file {bad_snapshot_path}.\n"
"The file may be corrupted or it was crafted in an incompatible format.")
expected_error(rpc_details=expected_error_msg)
def test_headers_not_synced(self, valid_snapshot_path):
for node in self.nodes[1:]:
assert_raises_rpc_error(-32603, "The base block header (3bb7ce5eba0be48939b7a521ac1ba9316afee2c7bada3a0cca24188e6d7d96c0) must appear in the headers chain. Make sure all headers are syncing, and call this RPC again.",