Skip to content

Commit

Permalink
Fixed subsidy_limit_test
Browse files Browse the repository at this point in the history
  • Loading branch information
psolstice committed Jun 28, 2022
1 parent d8699b4 commit b5c96dd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ class CMainParams : public CChainParams {

consensus.evoSporkKeyID = "a78fERshquPsTv2TuKMSsxTeKom56uBwLP";
consensus.nEvoSporkStartBlock = ZC_LELANTUS_STARTING_BLOCK;
consensus.nEvoSporkStopBlock = AdjustEndingBlockNumberAfterSubsidyHalving(ZC_LELANTUS_STARTING_BLOCK, 2*24*12*365, 486221); // two years after lelantus
consensus.nEvoSporkStopBlock = AdjustEndingBlockNumberAfterSubsidyHalving(ZC_LELANTUS_STARTING_BLOCK, 2*24*12*365, 486221); // =608035, two years after lelantus
consensus.nEvoSporkStopBlockExtensionVersion = 140903;
consensus.nEvoSporkStopBlockPrevious = ZC_LELANTUS_STARTING_BLOCK + 1*24*12*365; // one year after lelantus
consensus.nEvoSporkStopBlockExtensionGracefulPeriod = 24*12*14; // two weeks
Expand Down
18 changes: 12 additions & 6 deletions src/test/main_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,35 @@ BOOST_AUTO_TEST_CASE(subsidy_limit_test)
{
Consensus::Params consensusParams = Params(CBaseChainParams::MAIN).GetConsensus();
CAmount nSum = 0;
const int nMTPFirstBlock = 117564;
int lastHalving = (consensusParams.nSubsidyHalvingStopBlock - consensusParams.nSubsidyHalvingFirst)/consensusParams.nSubsidyHalvingInterval;
int lastHalvingBlock = consensusParams.nSubsidyHalvingFirst + lastHalving*consensusParams.nSubsidyHalvingInterval;
int lastHalving = (consensusParams.nSubsidyHalvingStopBlock - consensusParams.nSubsidyHalvingSecond)/consensusParams.nSubsidyHalvingInterval;
int lastHalvingBlock = consensusParams.nSubsidyHalvingSecond + lastHalving*consensusParams.nSubsidyHalvingInterval;

int step = 1;

for(int nHeight = 0; nHeight < 14000000; nHeight += step)
{
if (nHeight == consensusParams.nSubsidyHalvingFirst)
if (nHeight == consensusParams.nSubsidyHalvingSecond)
step = 1000;
else if (nHeight == lastHalvingBlock)
step = 1;
else if (nHeight == consensusParams.nSubsidyHalvingStopBlock)
step = 10000;

CAmount nSubsidy = GetBlockSubsidy(nHeight, consensusParams, nHeight<nMTPFirstBlock ? consensusParams.nMTPSwitchTime-1000 : consensusParams.nMTPSwitchTime);
int nTime;
if (nHeight < consensusParams.nMTPStartBlock)
nTime = consensusParams.nMTPSwitchTime-1000;
else if (nHeight < consensusParams.stage3StartBlock)
nTime = consensusParams.stage3StartTime-1000;
else
nTime = consensusParams.stage3StartTime;
CAmount nSubsidy = GetBlockSubsidy(nHeight, consensusParams, nTime);
if (nHeight == 0)
nSubsidy = 50*COIN;
BOOST_CHECK(nSubsidy <= 50 * COIN);
nSum += nSubsidy * step;
BOOST_CHECK(MoneyRange(nSum));
}
BOOST_CHECK_EQUAL(nSum, 2095751201171875ULL);
BOOST_CHECK_EQUAL(nSum, 2095751200767464ULL);
}

bool ReturnFalse() { return false; }
Expand Down

0 comments on commit b5c96dd

Please sign in to comment.