From faf7623106af2e106a3d9777d714d6afeb2bbd83 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 13 May 2021 12:54:14 +0200 Subject: fuzz: Call const member functions in addrman fuzz test only once --- src/test/fuzz/addrman.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'src/test') diff --git a/src/test/fuzz/addrman.cpp b/src/test/fuzz/addrman.cpp index 98ae32a8d0..b5b402829b 100644 --- a/src/test/fuzz/addrman.cpp +++ b/src/test/fuzz/addrman.cpp @@ -56,15 +56,6 @@ FUZZ_TARGET_INIT(addrman, initialize_addrman) [&] { (void)addr_man.SelectTriedCollision(); }, - [&] { - (void)addr_man.Select(fuzzed_data_provider.ConsumeBool()); - }, - [&] { - (void)addr_man.GetAddr( - /* max_addresses */ fuzzed_data_provider.ConsumeIntegralInRange(0, 4096), - /* max_pct */ fuzzed_data_provider.ConsumeIntegralInRange(0, 4096), - /* network */ std::nullopt); - }, [&] { const std::optional opt_address = ConsumeDeserializable(fuzzed_data_provider); const std::optional opt_net_addr = ConsumeDeserializable(fuzzed_data_provider); @@ -109,12 +100,16 @@ FUZZ_TARGET_INIT(addrman, initialize_addrman) if (opt_service) { addr_man.SetServices(*opt_service, ConsumeWeakEnum(fuzzed_data_provider, ALL_SERVICE_FLAGS)); } - }, - [&] { - (void)addr_man.Check(); }); } - (void)addr_man.size(); + const CAddrMan& const_addr_man{addr_man}; + (void)/*const_*/addr_man.GetAddr( + /* max_addresses */ fuzzed_data_provider.ConsumeIntegralInRange(0, 4096), + /* max_pct */ fuzzed_data_provider.ConsumeIntegralInRange(0, 4096), + /* network */ std::nullopt); + (void)/*const_*/addr_man.Check(); + (void)/*const_*/addr_man.Select(fuzzed_data_provider.ConsumeBool()); + (void)const_addr_man.size(); CDataStream data_stream(SER_NETWORK, PROTOCOL_VERSION); - data_stream << addr_man; + data_stream << const_addr_man; } -- cgit v1.2.3