mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-09 12:12:41 +01:00
fuzz: make FuzzedDataProvider usage deterministic
There exist many usages of `fuzzed_data_provider` where it is evaluated directly in the function call. Unfortunately, the order of evaluation of function arguments is unspecified. This means it can differ between compilers/version/optimization levels etc. But when the evaluation order changes, the same fuzzing input will produce different output, which is bad for coverage/reproducibility. This PR fixes all these cases where by moving multiple calls to `fuzzed_data_provider` out of the function arguments.
This commit is contained in:
@@ -85,17 +85,15 @@ FUZZ_TARGET(connman, .init = initialize_connman)
|
||||
(void)connman.ForNode(fuzzed_data_provider.ConsumeIntegral<NodeId>(), [&](auto) { return fuzzed_data_provider.ConsumeBool(); });
|
||||
},
|
||||
[&] {
|
||||
(void)connman.GetAddresses(
|
||||
/*max_addresses=*/fuzzed_data_provider.ConsumeIntegral<size_t>(),
|
||||
/*max_pct=*/fuzzed_data_provider.ConsumeIntegral<size_t>(),
|
||||
/*network=*/std::nullopt,
|
||||
/*filtered=*/fuzzed_data_provider.ConsumeBool());
|
||||
auto max_addresses = fuzzed_data_provider.ConsumeIntegral<size_t>();
|
||||
auto max_pct = fuzzed_data_provider.ConsumeIntegral<size_t>();
|
||||
auto filtered = fuzzed_data_provider.ConsumeBool();
|
||||
(void)connman.GetAddresses(max_addresses, max_pct, /*network=*/std::nullopt, filtered);
|
||||
},
|
||||
[&] {
|
||||
(void)connman.GetAddresses(
|
||||
/*requestor=*/random_node,
|
||||
/*max_addresses=*/fuzzed_data_provider.ConsumeIntegral<size_t>(),
|
||||
/*max_pct=*/fuzzed_data_provider.ConsumeIntegral<size_t>());
|
||||
auto max_addresses = fuzzed_data_provider.ConsumeIntegral<size_t>();
|
||||
auto max_pct = fuzzed_data_provider.ConsumeIntegral<size_t>();
|
||||
(void)connman.GetAddresses(/*requestor=*/random_node, max_addresses, max_pct);
|
||||
},
|
||||
[&] {
|
||||
(void)connman.GetDeterministicRandomizer(fuzzed_data_provider.ConsumeIntegral<uint64_t>());
|
||||
|
||||
Reference in New Issue
Block a user