| 15 | #include <vector> |
| 16 | |
| 17 | FUZZ_TARGET(node_eviction) |
| 18 | { |
| 19 | FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; |
| 20 | std::vector<NodeEvictionCandidate> eviction_candidates; |
| 21 | LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) { |
| 22 | eviction_candidates.push_back({ |
| 23 | /*id=*/fuzzed_data_provider.ConsumeIntegral<NodeId>(), |
| 24 | /*m_connected=*/std::chrono::seconds{fuzzed_data_provider.ConsumeIntegral<int64_t>()}, |
| 25 | /*m_min_ping_time=*/std::chrono::microseconds{fuzzed_data_provider.ConsumeIntegral<int64_t>()}, |
| 26 | /*m_last_block_time=*/std::chrono::seconds{fuzzed_data_provider.ConsumeIntegral<int64_t>()}, |
| 27 | /*m_last_tx_time=*/std::chrono::seconds{fuzzed_data_provider.ConsumeIntegral<int64_t>()}, |
| 28 | /*fRelevantServices=*/fuzzed_data_provider.ConsumeBool(), |
| 29 | /*fRelayTxes=*/fuzzed_data_provider.ConsumeBool(), |
| 30 | /*fBloomFilter=*/fuzzed_data_provider.ConsumeBool(), |
| 31 | /*nKeyedNetGroup=*/fuzzed_data_provider.ConsumeIntegral<uint64_t>(), |
| 32 | /*prefer_evict=*/fuzzed_data_provider.ConsumeBool(), |
| 33 | /*m_is_local=*/fuzzed_data_provider.ConsumeBool(), |
| 34 | /*m_network=*/fuzzed_data_provider.PickValueInArray(ALL_NETWORKS), |
| 35 | }); |
| 36 | } |
| 37 | // Make a copy since eviction_candidates may be in some valid but otherwise |
| 38 | // indeterminate state after the SelectNodeToEvict(&&) call. |
| 39 | const std::vector<NodeEvictionCandidate> eviction_candidates_copy = eviction_candidates; |
| 40 | const std::optional<NodeId> node_to_evict = SelectNodeToEvict(std::move(eviction_candidates)); |
| 41 | if (node_to_evict) { |
| 42 | assert(std::any_of(eviction_candidates_copy.begin(), eviction_candidates_copy.end(), [&node_to_evict](const NodeEvictionCandidate& eviction_candidate) { return *node_to_evict == eviction_candidate.id; })); |
| 43 | } |
| 44 | } |
nothing calls this directly
no test coverage detected