2018-04-11 13:06:27 +02:00
|
|
|
// Copyright (c) 2014-2018 The Dash Core developers
|
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <chainparams.h>
|
|
|
|
#include <validation.h>
|
2018-04-11 13:06:27 +02:00
|
|
|
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <test/test_dash.h>
|
2018-04-11 13:06:27 +02:00
|
|
|
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
|
|
|
|
BOOST_FIXTURE_TEST_SUITE(subsidy_tests, TestingSetup)
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(block_subsidy_test)
|
|
|
|
{
|
2017-05-09 09:29:12 +02:00
|
|
|
const auto chainParams = CreateChainParams(CBaseChainParams::MAIN);
|
2018-04-11 13:06:27 +02:00
|
|
|
|
|
|
|
uint32_t nPrevBits;
|
|
|
|
int32_t nPrevHeight;
|
|
|
|
CAmount nSubsidy;
|
|
|
|
|
|
|
|
// details for block 4249 (subsidy returned will be for block 4250)
|
|
|
|
nPrevBits = 0x1c4a47c4;
|
|
|
|
nPrevHeight = 4249;
|
2017-05-09 09:29:12 +02:00
|
|
|
nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
|
2018-04-11 13:06:27 +02:00
|
|
|
BOOST_CHECK_EQUAL(nSubsidy, 50000000000ULL);
|
|
|
|
|
|
|
|
// details for block 4501 (subsidy returned will be for block 4502)
|
|
|
|
nPrevBits = 0x1c4a47c4;
|
|
|
|
nPrevHeight = 4501;
|
2017-05-09 09:29:12 +02:00
|
|
|
nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
|
2018-04-11 13:06:27 +02:00
|
|
|
BOOST_CHECK_EQUAL(nSubsidy, 5600000000ULL);
|
|
|
|
|
|
|
|
// details for block 5464 (subsidy returned will be for block 5465)
|
|
|
|
nPrevBits = 0x1c29ec00;
|
|
|
|
nPrevHeight = 5464;
|
2017-05-09 09:29:12 +02:00
|
|
|
nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
|
2018-04-11 13:06:27 +02:00
|
|
|
BOOST_CHECK_EQUAL(nSubsidy, 2100000000ULL);
|
|
|
|
|
|
|
|
// details for block 5465 (subsidy returned will be for block 5466)
|
|
|
|
nPrevBits = 0x1c29ec00;
|
|
|
|
nPrevHeight = 5465;
|
2017-05-09 09:29:12 +02:00
|
|
|
nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
|
2018-04-11 13:06:27 +02:00
|
|
|
BOOST_CHECK_EQUAL(nSubsidy, 12200000000ULL);
|
|
|
|
|
|
|
|
// details for block 17588 (subsidy returned will be for block 17589)
|
|
|
|
nPrevBits = 0x1c08ba34;
|
|
|
|
nPrevHeight = 17588;
|
2017-05-09 09:29:12 +02:00
|
|
|
nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
|
2018-04-11 13:06:27 +02:00
|
|
|
BOOST_CHECK_EQUAL(nSubsidy, 6100000000ULL);
|
|
|
|
|
|
|
|
// details for block 99999 (subsidy returned will be for block 100000)
|
|
|
|
nPrevBits = 0x1b10cf42;
|
|
|
|
nPrevHeight = 99999;
|
2017-05-09 09:29:12 +02:00
|
|
|
nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
|
2018-04-11 13:06:27 +02:00
|
|
|
BOOST_CHECK_EQUAL(nSubsidy, 500000000ULL);
|
|
|
|
|
|
|
|
// details for block 210239 (subsidy returned will be for block 210240)
|
|
|
|
nPrevBits = 0x1b11548e;
|
|
|
|
nPrevHeight = 210239;
|
2017-05-09 09:29:12 +02:00
|
|
|
nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
|
2018-04-11 13:06:27 +02:00
|
|
|
BOOST_CHECK_EQUAL(nSubsidy, 500000000ULL);
|
|
|
|
|
|
|
|
// 1st subsidy reduction happens here
|
|
|
|
|
|
|
|
// details for block 210240 (subsidy returned will be for block 210241)
|
|
|
|
nPrevBits = 0x1b10d50b;
|
|
|
|
nPrevHeight = 210240;
|
2017-05-09 09:29:12 +02:00
|
|
|
nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
|
2018-04-11 13:06:27 +02:00
|
|
|
BOOST_CHECK_EQUAL(nSubsidy, 464285715ULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|