forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subsidy_tests.cpp
73 lines (57 loc) · 2.7 KB
/
subsidy_tests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Copyright (c) 2014-2020 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()