diff options
author | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-01-31 18:04:44 +0100 |
---|---|---|
committer | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-09-05 10:13:25 +0200 |
commit | fac81affb527132945773a5315bd27fec61ec52f (patch) | |
tree | 90aa401bd50bf12519a45737f335856256ff614e /src/test/netbase_tests.cpp | |
parent | faec591d64e40ba7ec7656cbfdda1a05953bde13 (diff) |
Use serialization parameters for CAddress serialization
This also cleans up the addrman (de)serialization code paths to only
allow `Disk` serialization. Some unit tests previously forced a
`Network` serialization, which does not make sense, because Bitcoin Core
in production will always `Disk` serialize.
This cleanup idea was suggested by Pieter Wuille and implemented by Anthony
Towns.
Co-authored-by: Pieter Wuille <pieter@wuille.net>
Co-authored-by: Anthony Towns <aj@erisian.com.au>
Diffstat (limited to 'src/test/netbase_tests.cpp')
-rw-r--r-- | src/test/netbase_tests.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/test/netbase_tests.cpp b/src/test/netbase_tests.cpp index 05953bfd10..e22bf7e7c0 100644 --- a/src/test/netbase_tests.cpp +++ b/src/test/netbase_tests.cpp @@ -559,35 +559,35 @@ static constexpr const char* stream_addrv2_hex = BOOST_AUTO_TEST_CASE(caddress_serialize_v1) { - CDataStream s(SER_NETWORK, PROTOCOL_VERSION); + DataStream s{}; - s << fixture_addresses; + s << WithParams(CAddress::V1_NETWORK, fixture_addresses); BOOST_CHECK_EQUAL(HexStr(s), stream_addrv1_hex); } BOOST_AUTO_TEST_CASE(caddress_unserialize_v1) { - CDataStream s(ParseHex(stream_addrv1_hex), SER_NETWORK, PROTOCOL_VERSION); + DataStream s{ParseHex(stream_addrv1_hex)}; std::vector<CAddress> addresses_unserialized; - s >> addresses_unserialized; + s >> WithParams(CAddress::V1_NETWORK, addresses_unserialized); BOOST_CHECK(fixture_addresses == addresses_unserialized); } BOOST_AUTO_TEST_CASE(caddress_serialize_v2) { - CDataStream s(SER_NETWORK, PROTOCOL_VERSION | ADDRV2_FORMAT); + DataStream s{}; - s << fixture_addresses; + s << WithParams(CAddress::V2_NETWORK, fixture_addresses); BOOST_CHECK_EQUAL(HexStr(s), stream_addrv2_hex); } BOOST_AUTO_TEST_CASE(caddress_unserialize_v2) { - CDataStream s(ParseHex(stream_addrv2_hex), SER_NETWORK, PROTOCOL_VERSION | ADDRV2_FORMAT); + DataStream s{ParseHex(stream_addrv2_hex)}; std::vector<CAddress> addresses_unserialized; - s >> addresses_unserialized; + s >> WithParams(CAddress::V2_NETWORK, addresses_unserialized); BOOST_CHECK(fixture_addresses == addresses_unserialized); } |