11#include <test/util/setup_common.h>
13#include <boost/test/unit_test.hpp>
21BOOST_FIXTURE_TEST_SUITE(proofcomparator_tests, TestingSetup)
30 std::numeric_limits<uint32_t>::max());
34 auto prevProof = proofMinScore;
35 for (
size_t i = 0; i < 100; i++) {
36 score += 1000 + GetRand<int>(10000);
38 BOOST_CHECK(comparator(higherScoreProof, proofMinScore));
39 BOOST_CHECK(comparator(higherScoreProof, prevProof));
40 BOOST_CHECK(!comparator(higherScoreProof, proofMaxScore));
41 prevProof = higherScoreProof;
46 for (
size_t i = 0; i < 100; i++) {
47 score -= 1 + GetRand<int>(100);
49 BOOST_CHECK(comparator(lowerScoreProof, proofMinScore));
50 BOOST_CHECK(!comparator(lowerScoreProof, prevProof));
51 BOOST_CHECK(!comparator(lowerScoreProof, proofMaxScore));
52 prevProof = lowerScoreProof;
55 for (
size_t i = 0; i < 100; i++) {
56 auto anotherProofMinScore =
59 anotherProofMinScore->getId() <
60 proofMinScore->getId());
66 std::vector<ProofRef> proofs;
67 for (
size_t i = 0; i < 100; i++) {
69 proofs.push_back(std::move(proof));
72 std::set<ProofRef, ProofRefComparatorByAddress> sortedProofs(proofs.begin(),
75 uintptr_t prevAddr = 0;
76 for (
const auto &p : sortedProofs) {
77 BOOST_CHECK_GE(
reinterpret_cast<uintptr_t
>(p.get()), prevAddr);
78 prevAddr =
reinterpret_cast<uintptr_t
>(p.get());
82BOOST_AUTO_TEST_SUITE_END()
#define Assert(val)
Identity function.
Chainstate stores and provides an API to update our local knowledge of the current best chain.
ProofRef buildRandomProof(Chainstate &active_chainstate, uint32_t score, int height, const CKey &masterKey)
constexpr uint32_t MIN_VALID_PROOF_SCORE
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
BOOST_AUTO_TEST_CASE(proof_shared_pointer_comparator)
Compare proofs by score, then by id in case of equality.