@ -91,9 +91,9 @@ void DeserializeFromFuzzingInput(FuzzBufferType buffer, T&& obj, const P& params
}
template < typename T >
CDataStream Serialize ( const T & obj , const int version = INIT_PROTO_VERSION , const int ser_type = SER_NETWORK )
CDataStream Serialize ( const T & obj )
{
CDataStream ds ( ser_type , version ) ;
CDataStream ds { SER_NETWORK , INIT_PROTO_VERSION } ;
ds < < obj ;
return ds ;
}
@ -107,12 +107,10 @@ T Deserialize(CDataStream ds)
}
template < typename T >
void DeserializeFromFuzzingInput ( FuzzBufferType buffer , T & & obj , const std : : optional < int > protocol_version = std : : nullopt , const int ser_type = SER_NETWORK )
void DeserializeFromFuzzingInput ( FuzzBufferType buffer , T & & obj )
{
CDataStream ds { buffer , SER_NETWORK , INIT_PROTO_VERSION } ;
{
CDataStream ds ( buffer , ser_type , INIT_PROTO_VERSION ) ;
if ( protocol_version ) {
ds . SetVersion ( * protocol_version ) ;
} else {
try {
int version ;
ds > > version ;
@ -135,9 +133,9 @@ void AssertEqualAfterSerializeDeserialize(const T& obj, const P& params)
assert ( Deserialize < T > ( Serialize ( obj , params ) , params ) = = obj ) ;
}
template < typename T >
void AssertEqualAfterSerializeDeserialize ( const T & obj , const int version = INIT_PROTO_VERSION , const int ser_type = SER_NETWORK )
void AssertEqualAfterSerializeDeserialize ( const T & obj )
{
assert ( Deserialize < T > ( Serialize ( obj , version , ser_type )) = = obj ) ;
assert ( Deserialize < T > ( Serialize ( obj )) = = obj ) ;
}
} // namespace
@ -254,7 +252,7 @@ FUZZ_TARGET(netaddr_deserialize, .init = initialize_deserialize)
if ( ! maybe_na ) return ;
const CNetAddr & na { * maybe_na } ;
if ( na . IsAddrV1Compatible ( ) ) {
AssertEqualAfterSerializeDeserialize ( na , C onsumeDeserializationParams< CNetAddr : : SerParams > ( fdp ) ) ;
AssertEqualAfterSerializeDeserialize ( na , C NetAddr: : V1 ) ;
}
AssertEqualAfterSerializeDeserialize ( na , CNetAddr : : V2 ) ;
}
@ -266,7 +264,7 @@ FUZZ_TARGET(service_deserialize, .init = initialize_deserialize)
if ( ! maybe_s ) return ;
const CService & s { * maybe_s } ;
if ( s . IsAddrV1Compatible ( ) ) {
AssertEqualAfterSerializeDeserialize ( s , C onsumeDeserializationParams< CNetAddr : : SerParams > ( fdp ) ) ;
AssertEqualAfterSerializeDeserialize ( s , C NetAddr: : V1 ) ;
}
AssertEqualAfterSerializeDeserialize ( s , CNetAddr : : V2 ) ;
if ( ser_params . enc = = CNetAddr : : Encoding : : V1 ) {
@ -281,8 +279,8 @@ FUZZ_TARGET_DESERIALIZE(messageheader_deserialize, {
FUZZ_TARGET ( address_deserialize , . init = initialize_deserialize )
{
FuzzedDataProvider fdp { buffer . data ( ) , buffer . size ( ) } ;
const auto ser_enc { ConsumeDeserializationParams < C Net Addr: : SerParams > ( fdp ) } ;
const auto maybe_a { ConsumeDeserializable < CAddress > ( fdp , CAddress: : SerParams { { ser_enc} , CAddress : : Format : : Network } ) } ;
const auto ser_enc { ConsumeDeserializationParams < C Address : : SerParams > ( fdp ) } ;
const auto maybe_a { ConsumeDeserializable < CAddress > ( fdp , ser_enc) } ;
if ( ! maybe_a ) return ;
const CAddress & a { * maybe_a } ;
// A CAddress in V1 mode will roundtrip