Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/peermanager_tests.cpp
Show First 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | for (int c = 0; c < 1000; c++) { | ||||
uint64_t start = next(); | uint64_t start = next(); | ||||
uint64_t stop = next(); | uint64_t stop = next(); | ||||
slots.emplace_back(start, stop); | slots.emplace_back(start, stop); | ||||
} | } | ||||
for (int k = 0; k < 100; k++) { | for (int k = 0; k < 100; k++) { | ||||
uint64_t s = InsecureRandRange(max); | uint64_t s = InsecureRandRange(max); | ||||
auto i = selectPeerImpl(slots, s, max); | auto i = selectPeerImpl(slots, s, max); | ||||
BOOST_CHECK(i == NO_PEER || | BOOST_CHECK(i == NO_PEER || slots[i].contains(s)); | ||||
(slots[i].start <= s && s < slots[i].stop)); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(add_peer) { | BOOST_AUTO_TEST_CASE(add_peer) { | ||||
// No peers. | // No peers. | ||||
PeerManager pm; | PeerManager pm; | ||||
BOOST_CHECK_EQUAL(pm.selectPeer(), NO_PEER); | BOOST_CHECK_EQUAL(pm.selectPeer(), NO_PEER); | ||||
▲ Show 20 Lines • Show All 128 Lines • Show Last 20 Lines |