0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-08 10:31:50 -05:00

Merge bitcoin/bitcoin#27549: fuzz: addrman, add coverage for network field in Select(), Size() and GetAddr()

35a2175ad8 fuzz: addrman, add coverage for `network` field in `Select()`, `Size()` and `GetAddr()` (brunoerg)

Pull request description:

  This PR adds fuzz coverage for `network` field in `Select()`, `Size()` and `GetAddr()`, there was only call to them without passing a network.
  https://marcofalke.github.io/b-c-cov/fuzz.coverage/src/addrman.cpp.gcov.html

ACKs for top commit:
  amitiuttarwar:
    for the record, ACK 35a2175ad8 - only small changes from the version (previously) proposed in 27213
  achow101:
    ACK 35a2175ad8
  mzumsande:
    Code Review ACK 35a2175ad8, haven't tested this yet, but I will let the fuzzer run for a while now.

Tree-SHA512: dddb8322298d6c373c8e68d57538470b11825a9a310a355828c351d5c0b19ff6779d024a800e3ea90126d0c050e86f71fd22cd23d1a306c784cef0f82c45e3ca
This commit is contained in:
Andrew Chow 2023-07-13 19:06:45 -04:00
commit ee467b8238
No known key found for this signature in database
GPG key ID: 17565732E08E5E41

View file

@ -300,12 +300,20 @@ FUZZ_TARGET_INIT(addrman, initialize_addrman)
});
}
const AddrMan& const_addr_man{addr_man};
std::optional<Network> network;
if (fuzzed_data_provider.ConsumeBool()) {
network = fuzzed_data_provider.PickValueInArray(ALL_NETWORKS);
}
(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.Select(fuzzed_data_provider.ConsumeBool());
(void)const_addr_man.Size();
network);
(void)const_addr_man.Select(fuzzed_data_provider.ConsumeBool(), network);
std::optional<bool> in_new;
if (fuzzed_data_provider.ConsumeBool()) {
in_new = fuzzed_data_provider.ConsumeBool();
}
(void)const_addr_man.Size(network, in_new);
CDataStream data_stream(SER_NETWORK, PROTOCOL_VERSION);
data_stream << const_addr_man;
}