Changeset View
Changeset View
Standalone View
Standalone View
src/test/versionbits_tests.cpp
Show First 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | public: | ||||
} | } | ||||
VersionBitsTester &TestDefined() { | VersionBitsTester &TestDefined() { | ||||
for (int i = 0; i < CHECKERS; i++) { | for (int i = 0; i < CHECKERS; i++) { | ||||
if (InsecureRandBits(i) == 0) { | if (InsecureRandBits(i) == 0) { | ||||
BOOST_CHECK_MESSAGE( | BOOST_CHECK_MESSAGE( | ||||
checker[i].GetStateFor(vpblock.empty() ? nullptr | checker[i].GetStateFor(vpblock.empty() ? nullptr | ||||
: vpblock.back()) == | : vpblock.back()) == | ||||
THRESHOLD_DEFINED, | ThresholdState::DEFINED, | ||||
strprintf("Test %i for DEFINED", num)); | strprintf("Test %i for DEFINED", num)); | ||||
} | } | ||||
} | } | ||||
num++; | num++; | ||||
return *this; | return *this; | ||||
} | } | ||||
VersionBitsTester &TestStarted() { | VersionBitsTester &TestStarted() { | ||||
for (int i = 0; i < CHECKERS; i++) { | for (int i = 0; i < CHECKERS; i++) { | ||||
if (InsecureRandBits(i) == 0) { | if (InsecureRandBits(i) == 0) { | ||||
BOOST_CHECK_MESSAGE( | BOOST_CHECK_MESSAGE( | ||||
checker[i].GetStateFor(vpblock.empty() ? nullptr | checker[i].GetStateFor(vpblock.empty() ? nullptr | ||||
: vpblock.back()) == | : vpblock.back()) == | ||||
THRESHOLD_STARTED, | ThresholdState::STARTED, | ||||
strprintf("Test %i for STARTED", num)); | strprintf("Test %i for STARTED", num)); | ||||
} | } | ||||
} | } | ||||
num++; | num++; | ||||
return *this; | return *this; | ||||
} | } | ||||
VersionBitsTester &TestLockedIn() { | VersionBitsTester &TestLockedIn() { | ||||
for (int i = 0; i < CHECKERS; i++) { | for (int i = 0; i < CHECKERS; i++) { | ||||
if (InsecureRandBits(i) == 0) { | if (InsecureRandBits(i) == 0) { | ||||
BOOST_CHECK_MESSAGE( | BOOST_CHECK_MESSAGE( | ||||
checker[i].GetStateFor(vpblock.empty() ? nullptr | checker[i].GetStateFor(vpblock.empty() ? nullptr | ||||
: vpblock.back()) == | : vpblock.back()) == | ||||
THRESHOLD_LOCKED_IN, | ThresholdState::LOCKED_IN, | ||||
strprintf("Test %i for LOCKED_IN", num)); | strprintf("Test %i for LOCKED_IN", num)); | ||||
} | } | ||||
} | } | ||||
num++; | num++; | ||||
return *this; | return *this; | ||||
} | } | ||||
VersionBitsTester &TestActive() { | VersionBitsTester &TestActive() { | ||||
for (int i = 0; i < CHECKERS; i++) { | for (int i = 0; i < CHECKERS; i++) { | ||||
if (InsecureRandBits(i) == 0) { | if (InsecureRandBits(i) == 0) { | ||||
BOOST_CHECK_MESSAGE( | BOOST_CHECK_MESSAGE( | ||||
checker[i].GetStateFor(vpblock.empty() ? nullptr | checker[i].GetStateFor(vpblock.empty() ? nullptr | ||||
: vpblock.back()) == | : vpblock.back()) == | ||||
THRESHOLD_ACTIVE, | ThresholdState::ACTIVE, | ||||
strprintf("Test %i for ACTIVE", num)); | strprintf("Test %i for ACTIVE", num)); | ||||
} | } | ||||
} | } | ||||
num++; | num++; | ||||
return *this; | return *this; | ||||
} | } | ||||
VersionBitsTester &TestFailed() { | VersionBitsTester &TestFailed() { | ||||
for (int i = 0; i < CHECKERS; i++) { | for (int i = 0; i < CHECKERS; i++) { | ||||
if (InsecureRandBits(i) == 0) { | if (InsecureRandBits(i) == 0) { | ||||
BOOST_CHECK_MESSAGE( | BOOST_CHECK_MESSAGE( | ||||
checker[i].GetStateFor(vpblock.empty() ? nullptr | checker[i].GetStateFor(vpblock.empty() ? nullptr | ||||
: vpblock.back()) == | : vpblock.back()) == | ||||
THRESHOLD_FAILED, | ThresholdState::FAILED, | ||||
strprintf("Test %i for FAILED", num)); | strprintf("Test %i for FAILED", num)); | ||||
} | } | ||||
} | } | ||||
num++; | num++; | ||||
return *this; | return *this; | ||||
} | } | ||||
CBlockIndex *Tip() { return vpblock.size() ? vpblock.back() : nullptr; } | CBlockIndex *Tip() { return vpblock.size() ? vpblock.back() : nullptr; } | ||||
▲ Show 20 Lines • Show All 210 Lines • Show Last 20 Lines |