From 18c8a0945bda554e121c2a684105dffd55505cd7 Mon Sep 17 00:00:00 2001 From: brunoerg Date: Mon, 5 Feb 2024 15:41:26 -0300 Subject: [PATCH] fuzz: move `ConsumeNetGroupManager` to util --- src/test/fuzz/addrman.cpp | 7 ------- src/test/fuzz/util/net.h | 8 ++++++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/test/fuzz/addrman.cpp b/src/test/fuzz/addrman.cpp index 570bcb2c136..a7e7f49d9f4 100644 --- a/src/test/fuzz/addrman.cpp +++ b/src/test/fuzz/addrman.cpp @@ -39,13 +39,6 @@ void initialize_addrman() g_setup = testing_setup.get(); } -[[nodiscard]] inline NetGroupManager ConsumeNetGroupManager(FuzzedDataProvider& fuzzed_data_provider) noexcept -{ - std::vector asmap = ConsumeRandomLengthBitVector(fuzzed_data_provider); - if (!SanityCheckASMap(asmap, 128)) asmap.clear(); - return NetGroupManager(asmap); -} - FUZZ_TARGET(data_stream_addr_man, .init = initialize_addrman) { FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; diff --git a/src/test/fuzz/util/net.h b/src/test/fuzz/util/net.h index e2cb34c68fd..cc73cdff4b7 100644 --- a/src/test/fuzz/util/net.h +++ b/src/test/fuzz/util/net.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -197,6 +198,13 @@ public: return FuzzedSock{fuzzed_data_provider}; } +[[nodiscard]] inline NetGroupManager ConsumeNetGroupManager(FuzzedDataProvider& fuzzed_data_provider) noexcept +{ + std::vector asmap = ConsumeRandomLengthBitVector(fuzzed_data_provider); + if (!SanityCheckASMap(asmap, 128)) asmap.clear(); + return NetGroupManager(asmap); +} + inline CSubNet ConsumeSubNet(FuzzedDataProvider& fuzzed_data_provider) noexcept { return {ConsumeNetAddr(fuzzed_data_provider), fuzzed_data_provider.ConsumeIntegral()};