Skip to content

Commit fa7eb4f

Browse files
author
MarcoFalke
committed
fuzz: Drop unused version from fuzz input format
1 parent 7bc8c53 commit fa7eb4f

File tree

3 files changed

+7
-32
lines changed

3 files changed

+7
-32
lines changed

src/test/fuzz/block.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <test/fuzz/fuzz.h>
1414
#include <util/chaintype.h>
1515
#include <validation.h>
16-
#include <version.h>
1716

1817
#include <cassert>
1918
#include <string>
@@ -25,12 +24,9 @@ void initialize_block()
2524

2625
FUZZ_TARGET(block, .init = initialize_block)
2726
{
28-
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
27+
DataStream ds{buffer};
2928
CBlock block;
3029
try {
31-
int nVersion;
32-
ds >> nVersion;
33-
ds.SetVersion(nVersion);
3430
ds >> TX_WITH_WITNESS(block);
3531
} catch (const std::ios_base::failure&) {
3632
return;

src/test/fuzz/deserialize.cpp

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include <test/fuzz/util.h>
2929
#include <test/util/setup_common.h>
3030
#include <undo.h>
31-
#include <version.h>
3231

3332
#include <exception>
3433
#include <optional>
@@ -91,15 +90,15 @@ void DeserializeFromFuzzingInput(FuzzBufferType buffer, T&& obj, const P& params
9190
}
9291

9392
template <typename T>
94-
CDataStream Serialize(const T& obj)
93+
DataStream Serialize(const T& obj)
9594
{
96-
CDataStream ds{SER_NETWORK, INIT_PROTO_VERSION};
95+
DataStream ds{};
9796
ds << obj;
9897
return ds;
9998
}
10099

101100
template <typename T>
102-
T Deserialize(CDataStream ds)
101+
T Deserialize(DataStream ds)
103102
{
104103
T obj;
105104
ds >> obj;
@@ -109,16 +108,7 @@ T Deserialize(CDataStream ds)
109108
template <typename T>
110109
void DeserializeFromFuzzingInput(FuzzBufferType buffer, T&& obj)
111110
{
112-
CDataStream ds{buffer, SER_NETWORK, INIT_PROTO_VERSION};
113-
{
114-
try {
115-
int version;
116-
ds >> version;
117-
ds.SetVersion(version);
118-
} catch (const std::ios_base::failure&) {
119-
throw invalid_fuzzing_input_exception();
120-
}
121-
}
111+
DataStream ds{buffer};
122112
try {
123113
ds >> obj;
124114
} catch (const std::ios_base::failure&) {

src/test/fuzz/transaction.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include <util/chaintype.h>
1919
#include <util/rbf.h>
2020
#include <validation.h>
21-
#include <version.h>
2221

2322
#include <cassert>
2423

@@ -29,14 +28,7 @@ void initialize_transaction()
2928

3029
FUZZ_TARGET(transaction, .init = initialize_transaction)
3130
{
32-
CDataStream ds(buffer, SER_NETWORK, INIT_PROTO_VERSION);
33-
try {
34-
int nVersion;
35-
ds >> nVersion;
36-
ds.SetVersion(nVersion);
37-
} catch (const std::ios_base::failure&) {
38-
return;
39-
}
31+
DataStream ds{buffer};
4032
bool valid_tx = true;
4133
const CTransaction tx = [&] {
4234
try {
@@ -47,12 +39,9 @@ FUZZ_TARGET(transaction, .init = initialize_transaction)
4739
}
4840
}();
4941
bool valid_mutable_tx = true;
50-
CDataStream ds_mtx(buffer, SER_NETWORK, INIT_PROTO_VERSION);
42+
DataStream ds_mtx{buffer};
5143
CMutableTransaction mutable_tx;
5244
try {
53-
int nVersion;
54-
ds_mtx >> nVersion;
55-
ds_mtx.SetVersion(nVersion);
5645
ds_mtx >> TX_WITH_WITNESS(mutable_tx);
5746
} catch (const std::ios_base::failure&) {
5847
valid_mutable_tx = false;

0 commit comments

Comments
 (0)