mirror of https://github.com/bitcoin/bitcoin
Merge 521de52c75
into a46065e36c
This commit is contained in:
commit
20e9140db7
|
@ -2771,7 +2771,15 @@ static RPCHelpMan loadtxoutset()
|
|||
}
|
||||
|
||||
SnapshotMetadata metadata;
|
||||
afile >> metadata;
|
||||
try {
|
||||
// Read data from the file
|
||||
afile >> metadata;
|
||||
} catch (const std::exception&) {
|
||||
// Handle any exception, which includes reaching the end of the file e.g. file size < sizeOf(metadata)
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR, strprintf("Unable to load UTXO snapshot, "
|
||||
"couldn't read snapshot metadata from file %s.\nThe file may be corrupted "
|
||||
"or it was crafted in an incompatible format.", path.utf8string()));
|
||||
}
|
||||
|
||||
uint256 base_blockhash = metadata.m_base_blockhash;
|
||||
if (!chainman.GetParams().AssumeutxoForBlockhash(base_blockhash).has_value()) {
|
||||
|
|
|
@ -111,6 +111,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.",
|
||||
|
|
Loading…
Reference in New Issue