10#include <test/util/setup_common.h>
12#include <boost/test/unit_test.hpp>
20BOOST_FIXTURE_TEST_SUITE(proofcomparator_tests, TestingSetup)
29 std::numeric_limits<uint32_t>::max());
33 auto prevProof = proofMinScore;
34 for (
size_t i = 0; i < 100; i++) {
35 score += 1000 + GetRand<int>(10000);
37 BOOST_CHECK(comparator(higherScoreProof, proofMinScore));
38 BOOST_CHECK(comparator(higherScoreProof, prevProof));
39 BOOST_CHECK(!comparator(higherScoreProof, proofMaxScore));
40 prevProof = higherScoreProof;
45 for (
size_t i = 0; i < 100; i++) {
46 score -= 1 + GetRand<int>(100);
48 BOOST_CHECK(comparator(lowerScoreProof, proofMinScore));
49 BOOST_CHECK(!comparator(lowerScoreProof, prevProof));
50 BOOST_CHECK(!comparator(lowerScoreProof, proofMaxScore));
51 prevProof = lowerScoreProof;
54 for (
size_t i = 0; i < 100; i++) {
55 auto anotherProofMinScore =
58 anotherProofMinScore->getId() <
59 proofMinScore->getId());
65 std::vector<ProofRef> proofs;
66 for (
size_t i = 0; i < 100; i++) {
68 proofs.push_back(std::move(proof));
71 std::set<ProofRef, ProofRefComparatorByAddress> sortedProofs(proofs.begin(),
74 uintptr_t prevAddr = 0;
75 for (
const auto &p : sortedProofs) {
76 BOOST_CHECK_GE(
reinterpret_cast<uintptr_t
>(p.get()), prevAddr);
77 prevAddr =
reinterpret_cast<uintptr_t
>(p.get());
81BOOST_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.