mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
fuzz: Drop unused version from fuzz input format
This commit is contained in:
parent
7bc8c5312b
commit
fa7eb4f5c3
3 changed files with 7 additions and 32 deletions
|
@ -13,7 +13,6 @@
|
|||
#include <test/fuzz/fuzz.h>
|
||||
#include <util/chaintype.h>
|
||||
#include <validation.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
@ -25,12 +24,9 @@ void initialize_block()
|
|||
|
||||
FUZZ_TARGET(block, .init = initialize_block)
|
||||
{
|
||||
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
|
||||
DataStream ds{buffer};
|
||||
CBlock block;
|
||||
try {
|
||||
int nVersion;
|
||||
ds >> nVersion;
|
||||
ds.SetVersion(nVersion);
|
||||
ds >> TX_WITH_WITNESS(block);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
return;
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include <test/fuzz/util.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <undo.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <exception>
|
||||
#include <optional>
|
||||
|
@ -91,15 +90,15 @@ void DeserializeFromFuzzingInput(FuzzBufferType buffer, T&& obj, const P& params
|
|||
}
|
||||
|
||||
template <typename T>
|
||||
CDataStream Serialize(const T& obj)
|
||||
DataStream Serialize(const T& obj)
|
||||
{
|
||||
CDataStream ds{SER_NETWORK, INIT_PROTO_VERSION};
|
||||
DataStream ds{};
|
||||
ds << obj;
|
||||
return ds;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T Deserialize(CDataStream ds)
|
||||
T Deserialize(DataStream ds)
|
||||
{
|
||||
T obj;
|
||||
ds >> obj;
|
||||
|
@ -109,16 +108,7 @@ T Deserialize(CDataStream ds)
|
|||
template <typename T>
|
||||
void DeserializeFromFuzzingInput(FuzzBufferType buffer, T&& obj)
|
||||
{
|
||||
CDataStream ds{buffer, SER_NETWORK, INIT_PROTO_VERSION};
|
||||
{
|
||||
try {
|
||||
int version;
|
||||
ds >> version;
|
||||
ds.SetVersion(version);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
throw invalid_fuzzing_input_exception();
|
||||
}
|
||||
}
|
||||
DataStream ds{buffer};
|
||||
try {
|
||||
ds >> obj;
|
||||
} catch (const std::ios_base::failure&) {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <util/chaintype.h>
|
||||
#include <util/rbf.h>
|
||||
#include <validation.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
|
@ -29,14 +28,7 @@ void initialize_transaction()
|
|||
|
||||
FUZZ_TARGET(transaction, .init = initialize_transaction)
|
||||
{
|
||||
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
|
||||
try {
|
||||
int nVersion;
|
||||
ds >> nVersion;
|
||||
ds.SetVersion(nVersion);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
return;
|
||||
}
|
||||
DataStream ds{buffer};
|
||||
bool valid_tx = true;
|
||||
const CTransaction tx = [&] {
|
||||
try {
|
||||
|
@ -47,12 +39,9 @@ FUZZ_TARGET(transaction, .init = initialize_transaction)
|
|||
}
|
||||
}();
|
||||
bool valid_mutable_tx = true;
|
||||
CDataStream ds_mtx(buffer, SER_NETWORK, INIT_PROTO_VERSION);
|
||||
DataStream ds_mtx{buffer};
|
||||
CMutableTransaction mutable_tx;
|
||||
try {
|
||||
int nVersion;
|
||||
ds_mtx >> nVersion;
|
||||
ds_mtx.SetVersion(nVersion);
|
||||
ds_mtx >> TX_WITH_WITNESS(mutable_tx);
|
||||
} catch (const std::ios_base::failure&) {
|
||||
valid_mutable_tx = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue