Changeset View
Changeset View
Standalone View
Standalone View
src/test/avalanche_tests.cpp
Show First 20 Lines • Show All 790 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(event_loop) { | ||||
// There is no query in flight at the moment. | // There is no query in flight at the moment. | ||||
BOOST_CHECK_EQUAL(AvalancheTest::getSuitableNodeToQuery(p), nodeid); | BOOST_CHECK_EQUAL(AvalancheTest::getSuitableNodeToQuery(p), nodeid); | ||||
// Add a new block. Check it is added to the polls. | // Add a new block. Check it is added to the polls. | ||||
uint64_t queryRound = AvalancheTest::getRound(p); | uint64_t queryRound = AvalancheTest::getRound(p); | ||||
BOOST_CHECK(p.addBlockToReconcile(pindex)); | BOOST_CHECK(p.addBlockToReconcile(pindex)); | ||||
for (int i = 0; i < 1000; i++) { | for (int i = 0; i < 60 * 1000; i++) { | ||||
// Technically, this is a race condition, but this should do just fine | // Technically, this is a race condition, but this should do just fine | ||||
// as we wait up to 1s for an event that should take 10ms. | // as we wait up to 1 minute for an event that should take 10ms. | ||||
boost::this_thread::sleep_for(boost::chrono::milliseconds(1)); | boost::this_thread::sleep_for(boost::chrono::milliseconds(1)); | ||||
if (AvalancheTest::getRound(p) != queryRound) { | if (AvalancheTest::getRound(p) != queryRound) { | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
// Check that we effectively got a request and not timed out. | // Check that we effectively got a request and not timed out. | ||||
BOOST_CHECK(AvalancheTest::getRound(p) > queryRound); | BOOST_CHECK(AvalancheTest::getRound(p) > queryRound); | ||||
▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines |