diff options
author | John Newbery <john@johnnewbery.com> | 2021-08-05 14:08:48 +0100 |
---|---|---|
committer | John Newbery <john@johnnewbery.com> | 2021-08-19 11:26:53 +0100 |
commit | 406be5ff9699874dc1d38d11f036e33cbdb820c9 (patch) | |
tree | 4637e90a588ec23dcff5d539ecef3319dcb25eaa /src/test/fuzz/addrman.cpp | |
parent | ed9ba8af08f857bda3ce2f77413317374c22d7b4 (diff) | |
download | bitcoin-406be5ff9699874dc1d38d11f036e33cbdb820c9.tar.xz |
[addrman] Remove all public uses of CAddrMan.Clear() from the tests
Just use unique_ptr<CAddrMan>s and reset the pointer if a frest addrman is required.
Also make CAddrMan::Clear() private to ensure that no call sites are missed.
Diffstat (limited to 'src/test/fuzz/addrman.cpp')
-rw-r--r-- | src/test/fuzz/addrman.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/test/fuzz/addrman.cpp b/src/test/fuzz/addrman.cpp index bc41180a8f..95aa53bff4 100644 --- a/src/test/fuzz/addrman.cpp +++ b/src/test/fuzz/addrman.cpp @@ -228,25 +228,23 @@ FUZZ_TARGET_INIT(addrman, initialize_addrman) { FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); SetMockTime(ConsumeTime(fuzzed_data_provider)); - CAddrManDeterministic addr_man{fuzzed_data_provider}; + auto addr_man_ptr = std::make_unique<CAddrManDeterministic>(fuzzed_data_provider); if (fuzzed_data_provider.ConsumeBool()) { const std::vector<uint8_t> serialized_data{ConsumeRandomLengthByteVector(fuzzed_data_provider)}; CDataStream ds(serialized_data, SER_DISK, INIT_PROTO_VERSION); const auto ser_version{fuzzed_data_provider.ConsumeIntegral<int32_t>()}; ds.SetVersion(ser_version); try { - ds >> addr_man; + ds >> *addr_man_ptr; } catch (const std::ios_base::failure&) { - addr_man.Clear(); + addr_man_ptr = std::make_unique<CAddrManDeterministic>(fuzzed_data_provider); } } + CAddrManDeterministic& addr_man = *addr_man_ptr; while (fuzzed_data_provider.ConsumeBool()) { CallOneOf( fuzzed_data_provider, [&] { - addr_man.Clear(); - }, - [&] { addr_man.ResolveCollisions(); }, [&] { |