Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14864839
D9767.id29141.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Subscribers
None
D9767.id29141.diff
View Options
diff --git a/src/avalanche/test/peermanager_tests.cpp b/src/avalanche/test/peermanager_tests.cpp
--- a/src/avalanche/test/peermanager_tests.cpp
+++ b/src/avalanche/test/peermanager_tests.cpp
@@ -599,4 +599,40 @@
}
}
+BOOST_AUTO_TEST_CASE(proof_accessors) {
+ avalanche::PeerManager pm;
+
+ constexpr int numProofs = 10;
+
+ std::vector<std::shared_ptr<Proof>> proofs;
+ proofs.reserve(numProofs);
+ for (int i = 0; i < numProofs; i++) {
+ proofs.push_back(getRandomProofPtr(MIN_VALID_PROOF_SCORE));
+ }
+
+ 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(
+ !pm.registerProof(std::make_shared<Proof>(std::move(badProof))));
+}
+
BOOST_AUTO_TEST_SUITE_END()
diff --git a/src/avalanche/test/processor_tests.cpp b/src/avalanche/test/processor_tests.cpp
--- a/src/avalanche/test/processor_tests.cpp
+++ b/src/avalanche/test/processor_tests.cpp
@@ -970,40 +970,4 @@
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()
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, May 20, 22:46 (4 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5861969
Default Alt Text
D9767.id29141.diff (2 KB)
Attached To
D9767: [avalanche] Move the proof accessor tests to the peer manager tests
Event Timeline
Log In to Comment