Update tests to account for decreased block interval

This commit is contained in:
Jack Grigg
2016-06-07 17:12:16 +12:00
parent 45e3deea8a
commit a59c352cfd
2 changed files with 131 additions and 125 deletions

View File

@@ -15,7 +15,7 @@ BOOST_FIXTURE_TEST_SUITE(main_tests, TestingSetup)
static void TestBlockSubsidyHalvings(const Consensus::Params& consensusParams)
{
int maxHalvings = 64;
CAmount nInitialSubsidy = 50 * COIN;
CAmount nInitialSubsidy = 12.5 * COIN;
CAmount nPreviousSubsidy = nInitialSubsidy * 2; // for height == 0
BOOST_CHECK_EQUAL(nPreviousSubsidy, nInitialSubsidy * 2);
@@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(subsidy_limit_test)
// Mining slow start
for (int nHeight = 0; nHeight < consensusParams.nSubsidySlowStartInterval; nHeight ++) {
CAmount nSubsidy = GetBlockSubsidy(nHeight, consensusParams);
BOOST_CHECK(nSubsidy <= 50 * COIN);
BOOST_CHECK(nSubsidy <= 12.5 * COIN);
nSum += nSubsidy;
BOOST_CHECK(MoneyRange(nSum));
}
@@ -63,19 +63,25 @@ BOOST_AUTO_TEST_CASE(subsidy_limit_test)
// Remainder of first period
for (int nHeight = consensusParams.nSubsidySlowStartInterval; nHeight < consensusParams.nSubsidyHalvingInterval + consensusParams.SubsidySlowStartShift(); nHeight ++) {
CAmount nSubsidy = GetBlockSubsidy(nHeight, consensusParams);
BOOST_CHECK(nSubsidy <= 50 * COIN);
BOOST_CHECK(nSubsidy <= 12.5 * COIN);
nSum += nSubsidy;
BOOST_CHECK(MoneyRange(nSum));
}
BOOST_CHECK_EQUAL(nSum, 1050000000000000ULL);
// Regular mining
for (int nHeight = consensusParams.nSubsidyHalvingInterval + consensusParams.SubsidySlowStartShift(); nHeight < 14000000; nHeight += 1000) {
for (int nHeight = consensusParams.nSubsidyHalvingInterval + consensusParams.SubsidySlowStartShift(); nHeight < 56000000; nHeight += 1000) {
CAmount nSubsidy = GetBlockSubsidy(nHeight, consensusParams);
BOOST_CHECK(nSubsidy <= 50 * COIN);
BOOST_CHECK(nSubsidy <= 12.5 * COIN);
nSum += nSubsidy * 1000;
BOOST_CHECK(MoneyRange(nSum));
}
BOOST_CHECK_EQUAL(nSum, 2099999997690000ULL);
// Changing the block interval from 10 to 2.5 minutes causes truncation
// effects to occur earlier (from the 9th halving interval instead of the
// 11th), decreasing the total monetary supply by 0.0693 ZEC. If the
// transaction output field is widened, this discrepancy will become smaller
// or disappear entirely.
//BOOST_CHECK_EQUAL(nSum, 2099999997690000ULL);
BOOST_CHECK_EQUAL(nSum, 2099999990760000ULL);
}
bool ReturnFalse() { return false; }