7 #include <test/util/setup_common.h>
9 #include <boost/test/unit_test.hpp>
18 if (currentNodeId >= 8) {
27 #define REGISTER_VOTE_AND_CHECK(vr, vote, state, finalized, stale, confidence) \
28 vr.registerVote(nextNodeId(), vote); \
29 BOOST_CHECK_EQUAL(vr.isAccepted(), state); \
30 BOOST_CHECK_EQUAL(vr.hasFinalized(), finalized); \
31 BOOST_CHECK_EQUAL(vr.isStale(), stale); \
32 BOOST_CHECK_EQUAL(vr.getConfidence(), confidence);
52 for (
int i = 0; i < 6; i++) {
62 for (
int i = 2; i < 8; i++) {
69 for (
int i = 2; i < 8; i++) {
83 for (
int i = 0; i < 5; i++) {
94 for (
int i = 2; i < 8; i++) {
101 for (
int i = 2; i < 8; i++) {
128 for (
int j = 1; j < i; j++) {
146 for (
auto j = 0; j < 6; j++) {
161 for (uint32_t vote = 0; vote <= 1; vote++) {
167 for (
auto i = 0; i < 5; i++) {
172 for (uint32_t i = 0; i < confidence; i++) {
176 uint32_t remainingVotes =
181 if (confidence == 1) {
193 for (uint32_t i = 0; i < remainingVotes; i++) {
214 for (uint32_t i = 0; i < 7; i++) {
217 for (uint32_t i = 0; i < 7; i++) {
238 for (uint32_t voteInit = 0; voteInit <= 1; voteInit++) {
241 uint32_t vote = voteInit;
246 for (
auto i = 0; i < offset; i++) {
252 for (
auto i = 0; i < 5; i++) {
266 goto finalsanitycheck;
273 goto finalsanitycheck;
286 for (
auto i = 0; i < 6; i++) {
291 goto finalsanitycheck;
315 for (
auto i = 0; i < 7; i++) {
322 for (
auto i = 0; i < 8; i++) {
329 auto expectedConfidence = 1;
330 for (
auto i = 0; i < 8; i++) {
333 for (
auto j = i; j < 8; j++) {
340 for (
auto i = 0; i < 90; i++) {
#define BOOST_AUTO_TEST_SUITE_END()
#define BOOST_FIXTURE_TEST_SUITE(a, b)
#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)