dash/src/test/subsidy_tests.cpp
Wladimir J. van der Laan 50652674b5 Merge #8855: Use a proper factory for creating chainparams
c1082a7 Chainparams: Use the factory for pow tests (Jorge Timón)
2351a06 Chainparams: Get rid of CChainParams& Params(std::string) (Jorge Timón)
f87f362 Chainparams: Use a regular factory for creating chainparams (Jorge Timón)

Tree-SHA512: 359c8a2a1bc9d02db7856d02810240ada28048ac088f878b575597a7255cdb0ffdd1a647085ee67a34c6a7e7ed9e6cfdb61240cf6e75139619b640dbb096072c
2019-06-26 12:45:10 -05:00

74 lines
2.7 KiB
C++

// 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.
#include "chainparams.h"
#include "validation.h"
#include "test/test_dash.h"
#include <boost/test/unit_test.hpp>
BOOST_FIXTURE_TEST_SUITE(subsidy_tests, TestingSetup)
BOOST_AUTO_TEST_CASE(block_subsidy_test)
{
const auto chainParams = CreateChainParams(CBaseChainParams::MAIN);
uint32_t nPrevBits;
int32_t nPrevHeight;
CAmount nSubsidy;
// details for block 4249 (subsidy returned will be for block 4250)
nPrevBits = 0x1c4a47c4;
nPrevHeight = 4249;
nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
BOOST_CHECK_EQUAL(nSubsidy, 50000000000ULL);
// details for block 4501 (subsidy returned will be for block 4502)
nPrevBits = 0x1c4a47c4;
nPrevHeight = 4501;
nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
BOOST_CHECK_EQUAL(nSubsidy, 5600000000ULL);
// details for block 5464 (subsidy returned will be for block 5465)
nPrevBits = 0x1c29ec00;
nPrevHeight = 5464;
nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
BOOST_CHECK_EQUAL(nSubsidy, 2100000000ULL);
// details for block 5465 (subsidy returned will be for block 5466)
nPrevBits = 0x1c29ec00;
nPrevHeight = 5465;
nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
BOOST_CHECK_EQUAL(nSubsidy, 12200000000ULL);
// details for block 17588 (subsidy returned will be for block 17589)
nPrevBits = 0x1c08ba34;
nPrevHeight = 17588;
nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
BOOST_CHECK_EQUAL(nSubsidy, 6100000000ULL);
// details for block 99999 (subsidy returned will be for block 100000)
nPrevBits = 0x1b10cf42;
nPrevHeight = 99999;
nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
BOOST_CHECK_EQUAL(nSubsidy, 500000000ULL);
// details for block 210239 (subsidy returned will be for block 210240)
nPrevBits = 0x1b11548e;
nPrevHeight = 210239;
nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
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;
nSubsidy = GetBlockSubsidy(nPrevBits, nPrevHeight, chainParams->GetConsensus(), false);
BOOST_CHECK_EQUAL(nSubsidy, 464285715ULL);
}
BOOST_AUTO_TEST_SUITE_END()