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