MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / FUZZ_TARGET

Function FUZZ_TARGET

src/test/fuzz/node_eviction.cpp:18–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16#include <vector>
17
18FUZZ_TARGET(node_eviction)
19{
20 FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()};
21 std::vector<NodeEvictionCandidate> eviction_candidates;
22 LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000)
23 {
24 eviction_candidates.push_back({
25 /*id=*/fuzzed_data_provider.ConsumeIntegral<NodeId>(),
26 /*m_connected=*/ConsumeTime(fuzzed_data_provider),
27 /*m_min_ping_time=*/ConsumeDuration<decltype(NodeEvictionCandidate::m_min_ping_time)>(fuzzed_data_provider, /*min=*/std::chrono::years{-1}, /*max=*/decltype(CNode::m_min_ping_time.load())::max()),
28 /*m_last_block_time=*/ConsumeTime(fuzzed_data_provider).time_since_epoch(),
29 /*m_last_tx_time=*/ConsumeTime(fuzzed_data_provider).time_since_epoch(),
30 /*fRelevantServices=*/fuzzed_data_provider.ConsumeBool(),
31 /*m_relay_txs=*/fuzzed_data_provider.ConsumeBool(),
32 /*fBloomFilter=*/fuzzed_data_provider.ConsumeBool(),
33 /*nKeyedNetGroup=*/fuzzed_data_provider.ConsumeIntegral<uint64_t>(),
34 /*prefer_evict=*/fuzzed_data_provider.ConsumeBool(),
35 /*m_is_local=*/fuzzed_data_provider.ConsumeBool(),
36 /*m_network=*/fuzzed_data_provider.PickValueInArray(ALL_NETWORKS),
37 /*m_noban=*/fuzzed_data_provider.ConsumeBool(),
38 /*m_conn_type=*/fuzzed_data_provider.PickValueInArray(ALL_CONNECTION_TYPES),
39 });
40 }
41 // Make a copy since eviction_candidates may be in some valid but otherwise
42 // indeterminate state after the SelectNodeToEvict(&&) call.
43 const std::vector<NodeEvictionCandidate> eviction_candidates_copy = eviction_candidates;
44 const std::optional<NodeId> node_to_evict = SelectNodeToEvict(std::move(eviction_candidates));
45 if (node_to_evict) {
46 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; }));
47 }
48}

Callers

nothing calls this directly

Calls 11

ConsumeTimeFunction · 0.85
SelectNodeToEvictFunction · 0.85
any_ofClass · 0.85
ConsumeBoolMethod · 0.80
PickValueInArrayMethod · 0.80
dataMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
loadMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected