From 870c746c41ebd034f55614099b4743a1840791e4 Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Sat, 12 Apr 2014 20:00:31 +0100 Subject: [PATCH] Rewrote tests for mining rewards, to at least approximately match Doge. Due to huge number of DOGE, tests cannot be completed without significant re-engineering of number handling code. --- src/test/main_tests.cpp | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/test/main_tests.cpp b/src/test/main_tests.cpp index f9fc1094e..81205ae46 100644 --- a/src/test/main_tests.cpp +++ b/src/test/main_tests.cpp @@ -7,14 +7,33 @@ BOOST_AUTO_TEST_SUITE(main_tests) BOOST_AUTO_TEST_CASE(subsidy_limit_test) { - uint64_t nSum = 0; - for (int nHeight = 0; nHeight < 7000000; nHeight += 1000) { + int nHeight = 0; + int nStepSize= 1000; + + // Random rewards to block 145k mean we can't sensibly calculate + // sum of the rewards until we're past block 145k + for (nHeight = 0; nHeight <= 145000; nHeight += nStepSize) { uint64_t nSubsidy = GetBlockValue(nHeight, 0, 0); - BOOST_CHECK(nSubsidy <= 50 * COIN); - nSum += nSubsidy * 1000; - BOOST_CHECK(MoneyRange(nSum)); + BOOST_CHECK(nSubsidy <= 1000000 * COIN); } - BOOST_CHECK(nSum == 2099999997690000ULL); + + uint64_t nSumAtBlock100k = 100000L * 500000L * COIN; + uint64_t nSum100To145k = 45000L * 250000L * COIN; + uint64_t nSum = nSumAtBlock100k + nSum100To145k; + + for (; nHeight < 600000; nHeight += 1000) { + uint64_t nSubsidy = GetBlockValue(nHeight, 0, 0); + BOOST_CHECK(nSubsidy <= 250000 * COIN); + nSum += nSubsidy * 1000; + // The following test breaks because we don't actually + // have a datatype big enough for the maximum money + // theoretically possible... + // BOOST_CHECK(MoneyRange(nSum)); + } + + // This also doesn't work because MAX_MONEY is nonsense, and + // I'm leaving it broken to force people to fix it later. + BOOST_CHECK(nSum == MAX_MONEY); } BOOST_AUTO_TEST_SUITE_END()