Changeset View
Changeset View
Standalone View
Standalone View
src/test/versionbits_tests.cpp
Show First 20 Lines • Show All 358 Lines • ▼ Show 20 Lines | for (int i = 0; i < 64; i++) { | ||||
.TestFailed() | .TestFailed() | ||||
.TestStateSinceHeight(6000); | .TestStateSinceHeight(6000); | ||||
} | } | ||||
// Sanity checks of version bit deployments | // Sanity checks of version bit deployments | ||||
const auto chainParams = CreateChainParams(CBaseChainParams::MAIN); | const auto chainParams = CreateChainParams(CBaseChainParams::MAIN); | ||||
const Consensus::Params &mainnetParams = chainParams->GetConsensus(); | const Consensus::Params &mainnetParams = chainParams->GetConsensus(); | ||||
for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; i++) { | for (int i = 0; i < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; i++) { | ||||
uint32_t bitmask = | uint32_t bitmask = VersionBitsMask( | ||||
VersionBitsMask(mainnetParams, (Consensus::DeploymentPos)i); | mainnetParams, static_cast<Consensus::DeploymentPos>(i)); | ||||
// Make sure that no deployment tries to set an invalid bit. | // Make sure that no deployment tries to set an invalid bit. | ||||
BOOST_CHECK_EQUAL(bitmask & ~(uint32_t)VERSIONBITS_TOP_MASK, bitmask); | BOOST_CHECK_EQUAL(bitmask & ~(uint32_t)VERSIONBITS_TOP_MASK, bitmask); | ||||
// Verify that the deployment windows of different deployment using the | // Verify that the deployment windows of different deployment using the | ||||
// same bit are disjoint. This test may need modification at such time | // same bit are disjoint. This test may need modification at such time | ||||
// as a new deployment is proposed that reuses the bit of an activated | // as a new deployment is proposed that reuses the bit of an activated | ||||
// soft fork, before the end time of that soft fork. (Alternatively, | // soft fork, before the end time of that soft fork. (Alternatively, | ||||
// the end time of that activated soft fork could be later changed to be | // the end time of that activated soft fork could be later changed to be | ||||
// earlier to avoid overlap.) | // earlier to avoid overlap.) | ||||
for (int j = i + 1; j < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; | for (int j = i + 1; j < (int)Consensus::MAX_VERSION_BITS_DEPLOYMENTS; | ||||
j++) { | j++) { | ||||
if (VersionBitsMask(mainnetParams, (Consensus::DeploymentPos)j) == | if (VersionBitsMask(mainnetParams, | ||||
static_cast<Consensus::DeploymentPos>(j)) == | |||||
bitmask) { | bitmask) { | ||||
BOOST_CHECK(mainnetParams.vDeployments[j].nStartTime > | BOOST_CHECK(mainnetParams.vDeployments[j].nStartTime > | ||||
mainnetParams.vDeployments[i].nTimeout || | mainnetParams.vDeployments[i].nTimeout || | ||||
mainnetParams.vDeployments[i].nStartTime > | mainnetParams.vDeployments[i].nStartTime > | ||||
mainnetParams.vDeployments[j].nTimeout); | mainnetParams.vDeployments[j].nTimeout); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
BOOST_AUTO_TEST_SUITE_END() | BOOST_AUTO_TEST_SUITE_END() |