Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/peermanager_tests.cpp
Show First 20 Lines • Show All 637 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 ProofRef &p) { | ||||
bool ret = false; | bool ret = false; | ||||
pm.forEachPeer([&](const Peer &peer) { | pm.forEachPeer([&](const Peer &peer) { | ||||
if (p->getId() == peer.proof->getId()) { | if (p->getId() == peer.proof->getId()) { | ||||
ret = true; | ret = true; | ||||
} | } | ||||
}); | }); | ||||
return ret; | return ret; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(dangling_node) { | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(proof_accessors) { | BOOST_AUTO_TEST_CASE(proof_accessors) { | ||||
avalanche::PeerManager pm; | avalanche::PeerManager pm; | ||||
constexpr int numProofs = 10; | constexpr int numProofs = 10; | ||||
std::vector<std::shared_ptr<Proof>> proofs; | std::vector<ProofRef> proofs; | ||||
proofs.reserve(numProofs); | proofs.reserve(numProofs); | ||||
for (int i = 0; i < numProofs; i++) { | for (int i = 0; i < numProofs; i++) { | ||||
proofs.push_back(buildRandomProof(MIN_VALID_PROOF_SCORE)); | proofs.push_back(buildRandomProof(MIN_VALID_PROOF_SCORE)); | ||||
} | } | ||||
for (int i = 0; i < numProofs; i++) { | for (int i = 0; i < numProofs; i++) { | ||||
BOOST_CHECK(pm.registerProof(proofs[i])); | BOOST_CHECK(pm.registerProof(proofs[i])); | ||||
// Fail to add an existing proof | // Fail to add an existing proof | ||||
Show All 23 Lines |