Changeset View
Changeset View
Standalone View
Standalone View
src/test/avalanche_tests.cpp
Show First 20 Lines • Show All 620 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(poll_and_response) { | ||||
AvalancheTest::runEventLoop(p); | AvalancheTest::runEventLoop(p); | ||||
BOOST_CHECK(p.registerVotes(avanodeid, resp, updates)); | BOOST_CHECK(p.registerVotes(avanodeid, resp, updates)); | ||||
BOOST_CHECK_EQUAL(updates.size(), 0); | BOOST_CHECK_EQUAL(updates.size(), 0); | ||||
BOOST_CHECK_EQUAL(AvalancheTest::getSuitableNodeToQuery(p), avanodeid); | BOOST_CHECK_EQUAL(AvalancheTest::getSuitableNodeToQuery(p), avanodeid); | ||||
connman->ClearNodes(); | connman->ClearNodes(); | ||||
} | } | ||||
#if BOOST_VERSION >= 105900 | |||||
BOOST_AUTO_TEST_CASE(poll_inflight_timeout, *boost::unit_test::timeout(60)) { | BOOST_AUTO_TEST_CASE(poll_inflight_timeout, *boost::unit_test::timeout(60)) { | ||||
#else | |||||
// TODO: Cleanup this branch when boost 1.58 is no longer supported. | |||||
BOOST_AUTO_TEST_CASE(poll_inflight_timeout) { | |||||
int64_t timeStart = GetTimeMillis(); | |||||
#endif | |||||
const Config &config = GetConfig(); | const Config &config = GetConfig(); | ||||
auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | auto connman = std::make_unique<CConnmanTest>(config, 0x1337, 0x1337); | ||||
auto peerLogic = | auto peerLogic = | ||||
std::make_unique<PeerLogicValidation>(connman.get(), scheduler, false); | std::make_unique<PeerLogicValidation>(connman.get(), scheduler, false); | ||||
AvalancheProcessor p(connman.get()); | AvalancheProcessor p(connman.get()); | ||||
Show All 11 Lines | auto avanode = | ||||
ConnectNode(config, NODE_AVALANCHE, *peerLogic, connman.get()); | ConnectNode(config, NODE_AVALANCHE, *peerLogic, connman.get()); | ||||
NodeId avanodeid = avanode->GetId(); | NodeId avanodeid = avanode->GetId(); | ||||
BOOST_CHECK(p.addPeer(avanodeid, 0)); | BOOST_CHECK(p.addPeer(avanodeid, 0)); | ||||
// Expire requests after some time. | // Expire requests after some time. | ||||
auto queryTimeDuration = std::chrono::milliseconds(10); | auto queryTimeDuration = std::chrono::milliseconds(10); | ||||
p.setQueryTimeoutDuration(queryTimeDuration); | p.setQueryTimeoutDuration(queryTimeDuration); | ||||
for (int i = 0; i < 10; i++) { | for (int i = 0; i < 10; i++) { | ||||
#if BOOST_VERSION < 105900 | |||||
// TODO: Cleanup this statement when boost 1.58 is no longer supported. | |||||
BOOST_REQUIRE(timeStart + 60 * 1000 > GetTimeMillis()); | |||||
#endif | |||||
AvalancheResponse resp = { | AvalancheResponse resp = { | ||||
AvalancheTest::getRound(p), 0, {AvalancheVote(0, blockHash)}}; | AvalancheTest::getRound(p), 0, {AvalancheVote(0, blockHash)}}; | ||||
auto start = std::chrono::steady_clock::now(); | auto start = std::chrono::steady_clock::now(); | ||||
AvalancheTest::runEventLoop(p); | AvalancheTest::runEventLoop(p); | ||||
// We cannot guarantee that we'll wait for just 1ms, so we have to bail | // We cannot guarantee that we'll wait for just 1ms, so we have to bail | ||||
// if we aren't within the proper time range. | // if we aren't within the proper time range. | ||||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); | std::this_thread::sleep_for(std::chrono::milliseconds(1)); | ||||
▲ Show 20 Lines • Show All 265 Lines • Show Last 20 Lines |