mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
tests: Add deserialization fuzzing of SnapshotMetadata (utxo_snapshot), uint160 and uint256
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include <key.h>
|
||||
#include <merkleblock.h>
|
||||
#include <net.h>
|
||||
#include <node/utxo_snapshot.h>
|
||||
#include <primitives/block.h>
|
||||
#include <protocol.h>
|
||||
#include <psbt.h>
|
||||
@@ -214,9 +215,24 @@ void test_one_input(const std::vector<uint8_t>& buffer)
|
||||
#elif BLOCKTRANSACTIONSREQUEST_DESERIALIZE
|
||||
BlockTransactionsRequest btr;
|
||||
DeserializeFromFuzzingInput(buffer, btr);
|
||||
#elif SNAPSHOTMETADATA_DESERIALIZE
|
||||
SnapshotMetadata snapshot_metadata;
|
||||
DeserializeFromFuzzingInput(buffer, snapshot_metadata);
|
||||
#elif UINT160_DESERIALIZE
|
||||
uint160 u160;
|
||||
DeserializeFromFuzzingInput(buffer, u160);
|
||||
AssertEqualAfterSerializeDeserialize(u160);
|
||||
#elif UINT256_DESERIALIZE
|
||||
uint256 u256;
|
||||
DeserializeFromFuzzingInput(buffer, u256);
|
||||
AssertEqualAfterSerializeDeserialize(u256);
|
||||
#else
|
||||
#error Need at least one fuzz target to compile
|
||||
#endif
|
||||
// Classes intentionally not covered in this file since their deserialization code is
|
||||
// fuzzed elsewhere:
|
||||
// * Deserialization of CTxOut is fuzzed in test/fuzz/tx_out.cpp
|
||||
// * Deserialization of CMutableTransaction is fuzzed in src/test/fuzz/transaction.cpp
|
||||
} catch (const invalid_fuzzing_input_exception&) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user