Changeset View
Changeset View
Standalone View
Standalone View
src/avalanche/test/processor_tests.cpp
Show First 20 Lines • Show All 964 Lines • ▼ Show 20 Lines | BOOST_AUTO_TEST_CASE(destructor) { | ||||
// Now that avalanche is destroyed, there is no more scheduled tasks. | // Now that avalanche is destroyed, there is no more scheduled tasks. | ||||
BOOST_CHECK_EQUAL(s.getQueueInfo(start, stop), 0); | BOOST_CHECK_EQUAL(s.getQueueInfo(start, stop), 0); | ||||
// Wait for the scheduler to stop. | // Wait for the scheduler to stop. | ||||
s.stop(true); | s.stop(true); | ||||
schedulerThread.join(); | schedulerThread.join(); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(proof_accessors) { | |||||
constexpr int numProofs = 10; | |||||
std::vector<std::shared_ptr<Proof>> proofs; | |||||
proofs.reserve(numProofs); | |||||
for (int i = 0; i < numProofs; i++) { | |||||
proofs.push_back(GetProof()); | |||||
} | |||||
m_processor->withPeerManager([&](avalanche::PeerManager &pm) { | |||||
for (int i = 0; i < numProofs; i++) { | |||||
BOOST_CHECK(pm.registerProof(proofs[i])); | |||||
// Fail to add an existing proof | |||||
BOOST_CHECK(!pm.registerProof(proofs[i])); | |||||
for (int added = 0; added <= i; added++) { | |||||
auto proof = pm.getProof(proofs[added]->getId()); | |||||
BOOST_CHECK(proof != nullptr); | |||||
const ProofId &proofid = proof->getId(); | |||||
BOOST_CHECK_EQUAL(proofid, proofs[added]->getId()); | |||||
} | |||||
} | |||||
}); | |||||
// No stake, copied from proof_tests.cpp | |||||
const std::string badProofHex( | |||||
"96527eae083f1f24625f049d9e54bb9a2102a93d98bf42ab90cfc0bf9e7c634ed76a7" | |||||
"3e95b02cacfd357b64e4fb6c92e92dd00"); | |||||
bilingual_str error; | |||||
Proof badProof; | |||||
BOOST_CHECK(Proof::FromHex(badProof, badProofHex, error)); | |||||
BOOST_CHECK( | |||||
!m_processor->addProof(std::make_shared<Proof>(std::move(badProof)))); | |||||
} | |||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |