Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/peermanager_tests.cpp
Show First 20 Lines • Show All 1,482 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(should_request_more_nodes) { | ||||
pm.cleanupDanglingProofs(ProofRef()); | pm.cleanupDanglingProofs(ProofRef()); | ||||
BOOST_CHECK(pm.shouldRequestMoreNodes()); | BOOST_CHECK(pm.shouldRequestMoreNodes()); | ||||
for (size_t i = 0; i < 10; i++) { | for (size_t i = 0; i < 10; i++) { | ||||
// The flag will not trigger again until the condition is met again | // The flag will not trigger again until the condition is met again | ||||
BOOST_CHECK(!pm.shouldRequestMoreNodes()); | BOOST_CHECK(!pm.shouldRequestMoreNodes()); | ||||
} | } | ||||
// Attempt to register the dangling proof again. This should fail but | |||||
// trigger a request for more nodes. | |||||
ProofRegistrationState state; | |||||
BOOST_CHECK(!pm.registerProof(proof2, state)); | |||||
BOOST_CHECK(state.GetResult() == ProofRegistrationResult::DANGLING); | |||||
BOOST_CHECK(pm.shouldRequestMoreNodes()); | |||||
for (size_t i = 0; i < 10; i++) { | |||||
// The flag will not trigger again until the condition is met again | |||||
BOOST_CHECK(!pm.shouldRequestMoreNodes()); | |||||
} | |||||
// Attach a node to that proof | // Attach a node to that proof | ||||
BOOST_CHECK(!pm.addNode(11, proof2->getId())); | BOOST_CHECK(!pm.addNode(11, proof2->getId())); | ||||
BOOST_CHECK(pm.registerProof(proof2)); | BOOST_CHECK(pm.registerProof(proof2)); | ||||
SetMockTime(GetTime() + 15 * 60); | SetMockTime(GetTime() + 15 * 60); | ||||
pm.cleanupDanglingProofs(ProofRef()); | pm.cleanupDanglingProofs(ProofRef()); | ||||
BOOST_CHECK(!pm.shouldRequestMoreNodes()); | BOOST_CHECK(!pm.shouldRequestMoreNodes()); | ||||
// Disconnect the node, the proof is dangling again | // Disconnect the node, the proof is dangling again | ||||
▲ Show 20 Lines • Show All 532 Lines • Show Last 20 Lines |