mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge bitcoin/bitcoin#22005: fuzz: Speed up banman fuzz target
fae0f836be57f466b5df094421c9fbf55fd8a2ed fuzz: Speed up banman fuzz target (MarcoFalke) Pull request description: Hopefully fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34463 ACKs for top commit: practicalswift: cr ACK fae0f836be57f466b5df094421c9fbf55fd8a2ed: patch looks correct and touches only `src/test/fuzz/banman.cpp` Tree-SHA512: edbad168c607d09a5f4a29639f2d0b852605dd61403334356ad35a1eac667b6ce3922b1b316fdf37a991195fbc24e947df9e37359231663f8a364e5889e28417
This commit is contained in:
parent
64f05c7941
commit
0e434051e3
@ -31,12 +31,16 @@ 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()};
|
||||
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,
|
||||
[&] {
|
||||
@ -50,7 +54,6 @@ FUZZ_TARGET_INIT(banman, initialize_banman)
|
||||
[&] {
|
||||
ban_man.ClearBanned();
|
||||
},
|
||||
[] {},
|
||||
[&] {
|
||||
ban_man.IsBanned(ConsumeNetAddr(fuzzed_data_provider));
|
||||
},
|
||||
@ -70,7 +73,6 @@ FUZZ_TARGET_INIT(banman, initialize_banman)
|
||||
[&] {
|
||||
ban_man.DumpBanlist();
|
||||
},
|
||||
[] {},
|
||||
[&] {
|
||||
ban_man.Discourage(ConsumeNetAddr(fuzzed_data_provider));
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user