Skip to content

Commit ee467b8

Browse files
committed
Merge bitcoin/bitcoin#27549: fuzz: addrman, add coverage for network field in Select(), Size() and GetAddr()
35a2175 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 35a2175 - only small changes from the version (previously) proposed in 27213 achow101: ACK 35a2175 mzumsande: Code Review ACK 35a2175, haven't tested this yet, but I will let the fuzzer run for a while now. Tree-SHA512: dddb8322298d6c373c8e68d57538470b11825a9a310a355828c351d5c0b19ff6779d024a800e3ea90126d0c050e86f71fd22cd23d1a306c784cef0f82c45e3ca
2 parents 05ad4de + 35a2175 commit ee467b8

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/test/fuzz/addrman.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,20 @@ FUZZ_TARGET_INIT(addrman, initialize_addrman)
300300
});
301301
}
302302
const AddrMan& const_addr_man{addr_man};
303+
std::optional<Network> network;
304+
if (fuzzed_data_provider.ConsumeBool()) {
305+
network = fuzzed_data_provider.PickValueInArray(ALL_NETWORKS);
306+
}
303307
(void)const_addr_man.GetAddr(
304308
/*max_addresses=*/fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 4096),
305309
/*max_pct=*/fuzzed_data_provider.ConsumeIntegralInRange<size_t>(0, 4096),
306-
/*network=*/std::nullopt);
307-
(void)const_addr_man.Select(fuzzed_data_provider.ConsumeBool());
308-
(void)const_addr_man.Size();
310+
network);
311+
(void)const_addr_man.Select(fuzzed_data_provider.ConsumeBool(), network);
312+
std::optional<bool> in_new;
313+
if (fuzzed_data_provider.ConsumeBool()) {
314+
in_new = fuzzed_data_provider.ConsumeBool();
315+
}
316+
(void)const_addr_man.Size(network, in_new);
309317
CDataStream data_stream(SER_NETWORK, PROTOCOL_VERSION);
310318
data_stream << const_addr_man;
311319
}

0 commit comments

Comments
 (0)