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

Method Check

src/test/fuzz/txrequest.cpp:288–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286 }
287
288 void Check()
289 {
290 // Compare CountTracked and CountLoad with naive structure.
291 size_t total = 0;
292 for (int peer = 0; peer < MAX_PEERS; ++peer) {
293 size_t tracked = 0;
294 size_t inflight = 0;
295 size_t candidates = 0;
296 for (int txhash = 0; txhash < MAX_TXHASHES; ++txhash) {
297 tracked += m_announcements[txhash][peer].m_state != State::NOTHING;
298 inflight += m_announcements[txhash][peer].m_state == State::REQUESTED;
299 candidates += m_announcements[txhash][peer].m_state == State::CANDIDATE;
300
301 std::bitset<MAX_PEERS> expected_announcers;
302 for (int peer = 0; peer < MAX_PEERS; ++peer) {
303 if (m_announcements[txhash][peer].m_state == State::CANDIDATE || m_announcements[txhash][peer].m_state == State::REQUESTED) {
304 expected_announcers[peer] = true;
305 }
306 }
307 std::vector<NodeId> candidate_peers;
308 m_tracker.GetCandidatePeers(TXHASHES[txhash], candidate_peers);
309 assert(expected_announcers.count() == candidate_peers.size());
310 for (const auto& peer : candidate_peers) {
311 assert(expected_announcers[peer]);
312 }
313 }
314 assert(m_tracker.Count(peer) == tracked);
315 assert(m_tracker.CountInFlight(peer) == inflight);
316 assert(m_tracker.CountCandidates(peer) == candidates);
317 total += tracked;
318 }
319 // Compare Size.
320 assert(m_tracker.Size() == total);
321
322 // Invoke internal consistency check of TxRequestTracker object.
323 m_tracker.SanityCheck();
324 }
325};
326} // namespace
327

Callers 2

FUZZ_TARGETFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45

Calls 8

countMethod · 0.80
GetCandidatePeersMethod · 0.45
sizeMethod · 0.45
CountMethod · 0.45
CountInFlightMethod · 0.45
CountCandidatesMethod · 0.45
SizeMethod · 0.45
SanityCheckMethod · 0.45

Tested by

no test coverage detected