7#include <test/util/random.h>
8#include <test/util/setup_common.h>
10#include <boost/test/unit_test.hpp>
28#define REGISTER_VOTE_AND_CHECK(vr, vote, state, finalized, stale, confidence) \
29 vr.registerVote(nextNodeId(), vote); \
30 BOOST_CHECK_EQUAL(vr.isAccepted(), state); \
31 BOOST_CHECK_EQUAL(vr.hasFinalized(), finalized); \
32 BOOST_CHECK_EQUAL(vr.isStale(), stale); \
33 BOOST_CHECK_EQUAL(vr.getConfidence(), confidence);
53 for (
int i = 0; i < 6; i++) {
63 for (
int i = 2; i < 8; i++) {
70 for (
int i = 2; i < 8; i++) {
84 for (
int i = 0; i < 5; i++) {
95 for (
int i = 2; i < 8; i++) {
102 for (
int i = 2; i < 8; i++) {
129 for (
int j = 1; j < i; j++) {
147 for (
auto j = 0; j < 6; j++) {
162 for (uint32_t vote = 0; vote <= 1; vote++) {
168 for (
auto i = 0; i < 5; i++) {
173 for (uint32_t i = 0; i < confidence; i++) {
177 uint32_t remainingVotes =
182 if (confidence == 1) {
194 for (uint32_t i = 0; i < remainingVotes; i++) {
215 for (uint32_t i = 0; i < 7; i++) {
218 for (uint32_t i = 0; i < 7; i++) {
239 for (uint32_t voteInit = 0; voteInit <= 1; voteInit++) {
242 uint32_t vote = voteInit;
247 for (
auto i = 0; i < offset; i++) {
253 for (
auto i = 0; i < 5; i++) {
267 goto finalsanitycheck;
274 goto finalsanitycheck;
287 for (
auto i = 0; i < 6; i++) {
292 goto finalsanitycheck;
316 for (
auto i = 0; i < 7; i++) {
323 for (
auto i = 0; i < 8; i++) {
330 auto expectedConfidence = 1;
331 for (
auto i = 0; i < 8; i++) {
334 for (
auto j = i; j < 8; j++) {
341 for (
auto i = 0; i < 90; i++) {
351BOOST_AUTO_TEST_SUITE_END()
#define BOOST_CHECK_EQUAL(v1, v2)
#define BOOST_CHECK(expr)
uint16_t getConfidence() const
void clearInflightRequest(uint8_t count=1)
Clear count inflight requests.
bool hasFinalized() const
bool shouldPoll() const
Return if this item is in condition to be polled at the moment.
bool registerVote(NodeId nodeid, uint32_t error)
Register a new vote for an item and update confidence accordingly.
bool isStale(uint32_t staleThreshold=AVALANCHE_VOTE_STALE_THRESHOLD, uint32_t staleFactor=AVALANCHE_VOTE_STALE_FACTOR) const
bool registerPoll() const
Register that a request is being made regarding that item.
bool isAccepted() const
Vote accounting facilities.
static constexpr uint32_t AVALANCHE_VOTE_STALE_FACTOR
Scaling factor applied to confidence to determine staleness threshold.
static constexpr int AVALANCHE_MAX_INFLIGHT_POLL
How many inflight requests can exist for one item.
static constexpr uint32_t AVALANCHE_VOTE_STALE_THRESHOLD
Number of votes before a record may be considered as stale.
static constexpr int AVALANCHE_FINALIZATION_SCORE
Finalization score.
#define REGISTER_VOTE_AND_CHECK(vr, vote, state, finalized, stale, confidence)
BOOST_AUTO_TEST_CASE(vote_record)