diff options
author | MarcoFalke <falke.marco@gmail.com> | 2021-05-20 18:06:41 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2021-05-20 18:03:47 +0200 |
commit | fae0f836be57f466b5df094421c9fbf55fd8a2ed (patch) | |
tree | d51e47daccefb2804957df5aade79aa74b1e27fa /src/test/fuzz/banman.cpp | |
parent | ea8b2e8e127b5a27424c1c08a1352ec1c9382c96 (diff) |
fuzz: Speed up banman fuzz target
Diffstat (limited to 'src/test/fuzz/banman.cpp')
-rw-r--r-- | src/test/fuzz/banman.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/test/fuzz/banman.cpp b/src/test/fuzz/banman.cpp index 8bf484722c..9ad964c3d6 100644 --- a/src/test/fuzz/banman.cpp +++ b/src/test/fuzz/banman.cpp @@ -32,13 +32,17 @@ void initialize_banman() FUZZ_TARGET_INIT(banman, initialize_banman) { + // The complexity is O(N^2), where N is the input size, because each call + // might call DumpBanlist (or other methods that are at least linear + // complexity of the input size). + int limit_max_ops{300}; FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; SetMockTime(ConsumeTime(fuzzed_data_provider)); const fs::path banlist_file = GetDataDir() / "fuzzed_banlist.dat"; fs::remove(banlist_file); { BanMan ban_man{banlist_file, nullptr, ConsumeBanTimeOffset(fuzzed_data_provider)}; - while (fuzzed_data_provider.ConsumeBool()) { + while (--limit_max_ops >= 0 && fuzzed_data_provider.ConsumeBool()) { CallOneOf( fuzzed_data_provider, [&] { @@ -52,7 +56,6 @@ FUZZ_TARGET_INIT(banman, initialize_banman) [&] { ban_man.ClearBanned(); }, - [] {}, [&] { ban_man.IsBanned(ConsumeNetAddr(fuzzed_data_provider)); }, @@ -72,7 +75,6 @@ FUZZ_TARGET_INIT(banman, initialize_banman) [&] { ban_man.DumpBanlist(); }, - [] {}, [&] { ban_man.Discourage(ConsumeNetAddr(fuzzed_data_provider)); }); |