7#include <test/util/random.h>
8#include <test/util/setup_common.h>
10#include <boost/test/unit_test.hpp>
30#define REGISTER_VOTE_AND_CHECK(vr, vote, state, finalized, stale, confidence) \
31 vr.registerVote(nextNodeId(), vote); \
32 BOOST_CHECK_EQUAL(vr.isAccepted(), state); \
33 BOOST_CHECK_EQUAL(vr.hasFinalized(), finalized); \
34 BOOST_CHECK_EQUAL(vr.isStale(), stale); \
35 BOOST_CHECK_EQUAL(vr.getConfidence(), confidence);
55 for (
int i = 0; i < 6; i++) {
65 for (
int i = 2; i < 8; i++) {
72 for (
int i = 2; i < 8; i++) {
86 for (
int i = 0; i < 5; i++) {
97 for (
int i = 2; i < 8; i++) {
104 for (
int i = 2; i < 8; i++) {
131 for (
int j = 1; j < i; j++) {
149 for (
auto j = 0; j < 6; j++) {
163 for (uint32_t vote = 0; vote <= 1; vote++) {
169 for (
auto i = 0; i < 5; i++) {
174 for (uint32_t i = 0; i < confidence; i++) {
178 uint32_t remainingVotes =
183 if (confidence == 1) {
195 for (uint32_t i = 0; i < remainingVotes; i++) {
216 for (uint32_t i = 0; i < 7; i++) {
219 for (uint32_t i = 0; i < 7; i++) {
240 for (uint32_t voteInit = 0; voteInit <= 1; voteInit++) {
243 uint32_t vote = voteInit;
248 for (
auto i = 0; i < offset; i++) {
254 for (
auto i = 0; i < 5; i++) {
268 goto finalsanitycheck;
275 goto finalsanitycheck;
288 for (
auto i = 0; i < 6; i++) {
293 goto finalsanitycheck;
317 for (
auto i = 0; i < 7; i++) {
324 for (
auto i = 0; i < 8; i++) {
331 auto expectedConfidence = 1;
332 for (
auto i = 0; i < 8; i++) {
335 for (
auto j = i; j < 8; j++) {
342 for (
auto i = 0; i < 90; i++) {
352BOOST_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)