Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/peermanager_tests.cpp
Show First 20 Lines • Show All 481 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(orphan_proofs) { | ||||
// Good | // Good | ||||
BOOST_CHECK(!pm.isOrphan(proof1->getId())); | BOOST_CHECK(!pm.isOrphan(proof1->getId())); | ||||
// MISSING_UTXO | // MISSING_UTXO | ||||
BOOST_CHECK(pm.isOrphan(proof2->getId())); | BOOST_CHECK(pm.isOrphan(proof2->getId())); | ||||
// HEIGHT_MISMATCH | // HEIGHT_MISMATCH | ||||
BOOST_CHECK(pm.isOrphan(proof3->getId())); | BOOST_CHECK(pm.isOrphan(proof3->getId())); | ||||
const auto isGoodPeer = [&pm](const std::shared_ptr<Proof> &p) { | const auto isGoodPeer = [&pm](const std::shared_ptr<Proof> &p) { | ||||
for (const auto &peer : pm.getPeers()) { | bool ret = false; | ||||
pm.forEachPeer([&](const Peer &peer) { | |||||
if (p->getId() == peer.proof->getId()) { | if (p->getId() == peer.proof->getId()) { | ||||
return true; | ret = true; | ||||
} | } | ||||
} | }); | ||||
return false; | return ret; | ||||
}; | }; | ||||
BOOST_CHECK(isGoodPeer(proof1)); | BOOST_CHECK(isGoodPeer(proof1)); | ||||
BOOST_CHECK(!isGoodPeer(proof2)); | BOOST_CHECK(!isGoodPeer(proof2)); | ||||
BOOST_CHECK(!isGoodPeer(proof3)); | BOOST_CHECK(!isGoodPeer(proof3)); | ||||
// Add outpoint2, proof2 is no longer considered orphan | // Add outpoint2, proof2 is no longer considered orphan | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |