@@ -91,9 +91,9 @@ void DeserializeFromFuzzingInput(FuzzBufferType buffer, T&& obj, const P& params
91
91
}
92
92
93
93
template <typename T>
94
- CDataStream Serialize (const T& obj, const int version = INIT_PROTO_VERSION, const int ser_type = SER_NETWORK )
94
+ CDataStream Serialize (const T& obj)
95
95
{
96
- CDataStream ds (ser_type, version) ;
96
+ CDataStream ds{SER_NETWORK, INIT_PROTO_VERSION} ;
97
97
ds << obj;
98
98
return ds;
99
99
}
@@ -107,12 +107,10 @@ T Deserialize(CDataStream ds)
107
107
}
108
108
109
109
template <typename T>
110
- void DeserializeFromFuzzingInput (FuzzBufferType buffer, T&& obj, const std::optional< int > protocol_version = std::nullopt, const int ser_type = SER_NETWORK )
110
+ void DeserializeFromFuzzingInput (FuzzBufferType buffer, T&& obj)
111
111
{
112
- CDataStream ds (buffer, ser_type, INIT_PROTO_VERSION);
113
- if (protocol_version) {
114
- ds.SetVersion (*protocol_version);
115
- } else {
112
+ CDataStream ds{buffer, SER_NETWORK, INIT_PROTO_VERSION};
113
+ {
116
114
try {
117
115
int version;
118
116
ds >> version;
@@ -135,9 +133,9 @@ void AssertEqualAfterSerializeDeserialize(const T& obj, const P& params)
135
133
assert (Deserialize<T>(Serialize (obj, params), params) == obj);
136
134
}
137
135
template <typename T>
138
- void AssertEqualAfterSerializeDeserialize (const T& obj, const int version = INIT_PROTO_VERSION, const int ser_type = SER_NETWORK )
136
+ void AssertEqualAfterSerializeDeserialize (const T& obj)
139
137
{
140
- assert (Deserialize<T>(Serialize (obj, version, ser_type )) == obj);
138
+ assert (Deserialize<T>(Serialize (obj)) == obj);
141
139
}
142
140
143
141
} // namespace
@@ -254,7 +252,7 @@ FUZZ_TARGET(netaddr_deserialize, .init = initialize_deserialize)
254
252
if (!maybe_na) return ;
255
253
const CNetAddr& na{*maybe_na};
256
254
if (na.IsAddrV1Compatible ()) {
257
- AssertEqualAfterSerializeDeserialize (na, ConsumeDeserializationParams< CNetAddr::SerParams>(fdp) );
255
+ AssertEqualAfterSerializeDeserialize (na, CNetAddr::V1 );
258
256
}
259
257
AssertEqualAfterSerializeDeserialize (na, CNetAddr::V2);
260
258
}
@@ -266,7 +264,7 @@ FUZZ_TARGET(service_deserialize, .init = initialize_deserialize)
266
264
if (!maybe_s) return ;
267
265
const CService& s{*maybe_s};
268
266
if (s.IsAddrV1Compatible ()) {
269
- AssertEqualAfterSerializeDeserialize (s, ConsumeDeserializationParams< CNetAddr::SerParams>(fdp) );
267
+ AssertEqualAfterSerializeDeserialize (s, CNetAddr::V1 );
270
268
}
271
269
AssertEqualAfterSerializeDeserialize (s, CNetAddr::V2);
272
270
if (ser_params.enc == CNetAddr::Encoding::V1) {
@@ -281,8 +279,8 @@ FUZZ_TARGET_DESERIALIZE(messageheader_deserialize, {
281
279
FUZZ_TARGET(address_deserialize, .init = initialize_deserialize)
282
280
{
283
281
FuzzedDataProvider fdp{buffer.data (), buffer.size ()};
284
- const auto ser_enc{ConsumeDeserializationParams<CNetAddr ::SerParams>(fdp)};
285
- const auto maybe_a{ConsumeDeserializable<CAddress>(fdp, CAddress::SerParams{{ ser_enc}, CAddress::Format::Network} )};
282
+ const auto ser_enc{ConsumeDeserializationParams<CAddress ::SerParams>(fdp)};
283
+ const auto maybe_a{ConsumeDeserializable<CAddress>(fdp, ser_enc)};
286
284
if (!maybe_a) return ;
287
285
const CAddress& a{*maybe_a};
288
286
// A CAddress in V1 mode will roundtrip
0 commit comments