Changeset View
Changeset View
Standalone View
Standalone View
src/test/activation_tests.cpp
Show All 17 Lines | static void SetMTP(std::array<CBlockIndex, 12> &blocks, int64_t mtp) { | ||||
for (size_t i = 0; i < len; ++i) { | for (size_t i = 0; i < len; ++i) { | ||||
blocks[i].nTime = mtp + (i - (len / 2)); | blocks[i].nTime = mtp + (i - (len / 2)); | ||||
} | } | ||||
BOOST_CHECK_EQUAL(blocks.back().GetMedianTimePast(), mtp); | BOOST_CHECK_EQUAL(blocks.back().GetMedianTimePast(), mtp); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(isgravitonenabled) { | |||||
CBlockIndex prev; | |||||
const Consensus::Params ¶ms = Params().GetConsensus(); | |||||
const auto activation = | |||||
gArgs.GetArg("-gravitonactivationtime", params.gravitonActivationTime); | |||||
SetMockTime(activation - 1000000); | |||||
BOOST_CHECK(!IsGravitonEnabled(params, nullptr)); | |||||
std::array<CBlockIndex, 12> blocks; | |||||
for (size_t i = 1; i < blocks.size(); ++i) { | |||||
blocks[i].pprev = &blocks[i - 1]; | |||||
} | |||||
BOOST_CHECK(!IsGravitonEnabled(params, &blocks.back())); | |||||
SetMTP(blocks, activation - 1); | |||||
BOOST_CHECK(!IsGravitonEnabled(params, &blocks.back())); | |||||
SetMTP(blocks, activation); | |||||
BOOST_CHECK(IsGravitonEnabled(params, &blocks.back())); | |||||
SetMTP(blocks, activation + 1); | |||||
BOOST_CHECK(IsGravitonEnabled(params, &blocks.back())); | |||||
} | |||||
BOOST_AUTO_TEST_CASE(isphononenabled) { | BOOST_AUTO_TEST_CASE(isphononenabled) { | ||||
if (!gArgs.GetBoolArg("-activatenextupgrade", false)) { | if (!gArgs.GetBoolArg("-activatenextupgrade", false)) { | ||||
CBlockIndex prev; | CBlockIndex prev; | ||||
const Consensus::Params ¶ms = Params().GetConsensus(); | const Consensus::Params ¶ms = Params().GetConsensus(); | ||||
const auto activation = | const auto activation = | ||||
gArgs.GetArg("-phononactivationtime", params.phononActivationTime); | gArgs.GetArg("-phononactivationtime", params.phononActivationTime); | ||||
SetMockTime(activation - 1000000); | SetMockTime(activation - 1000000); | ||||
Show All 38 Lines |