mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-06 14:19:59 -05:00
Merge bitcoin/bitcoin#21941: fuzz: Call const member functions in addrman fuzz test only once
faf7623106
fuzz: Call const member functions in addrman fuzz test only once (MarcoFalke) Pull request description: Logically based on #21940 Currently the fuzz test may spend a long time generating random numbers:  Fix that by calling const member functions only once. Hopefully fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34224 ACKs for top commit: practicalswift: cr ACKfaf7623106
: touches only `src/test/fuzz/addrman.cpp` Tree-SHA512: 0fe9e0111eb1706fc39bd2f90d4b87a771882bada54c01e96d8e79c2afca2f1081139d5ab680285a81835cc5142e74ada422a181db34b01904975d1e167e64c2
This commit is contained in:
commit
d75a1df617
1 changed files with 9 additions and 14 deletions
|
@ -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<size_t>(0, 4096),
|
||||
/* max_pct */ fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 4096),
|
||||
/* network */ std::nullopt);
|
||||
},
|
||||
[&] {
|
||||
const std::optional<CAddress> opt_address = ConsumeDeserializable<CAddress>(fuzzed_data_provider);
|
||||
const std::optional<CNetAddr> opt_net_addr = ConsumeDeserializable<CNetAddr>(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<size_t>(0, 4096),
|
||||
/* max_pct */ fuzzed_data_provider.ConsumeIntegralInRange<size_t>(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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue