Skip to content
Permalink
Browse files

Add unit test for budget value.

Prevent any future issues with calculated budget value by adding a unit test.
  • Loading branch information...
presstab committed May 2, 2018
1 parent 413fad9 commit 68cea3e39e402aedd73ac33d1786308791c57199
Showing with 32 additions and 0 deletions.
  1. +1 −0 src/Makefile.test.include
  2. +31 −0 src/test/budget_tests.cpp
@@ -48,6 +48,7 @@ BITCOIN_TESTS =\
test/base32_tests.cpp \
test/base58_tests.cpp \
test/base64_tests.cpp \
test/budget_tests.cpp \
test/checkblock_tests.cpp \
test/Checkpoints_tests.cpp \
test/coins_tests.cpp \
@@ -0,0 +1,31 @@
// Copyright (c) 2018 The PIVX developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <boost/test/unit_test.hpp>
#include <tinyformat.h>
#include <utilmoneystr.h>
#include "masternode-budget.h"

BOOST_AUTO_TEST_SUITE(budget_tests)

void CheckBudgetValue(int nHeight, std::string strNetwork, CAmount nExpectedValue)
{
CBudgetManager budget;
CAmount nBudget = budget.GetTotalBudget(nHeight);
std::string strError = strprintf("Budget is not as expected for %s. Result: %s, Expected: %s", strNetwork, FormatMoney(nBudget), FormatMoney(nExpectedValue));
BOOST_CHECK_MESSAGE(nBudget == nExpectedValue, strError);
}

BOOST_AUTO_TEST_CASE(budget_value)
{
SelectParams(CBaseChainParams::MAIN);
int nHeightTest = Params().Zerocoin_Block_V2_Start() + 1;
CheckBudgetValue(nHeightTest, "mainnet", 43200*COIN);

SelectParams(CBaseChainParams::TESTNET);
nHeightTest = Params().Zerocoin_Block_V2_Start() + 1;
CheckBudgetValue(nHeightTest, "testnet", 7300*COIN);
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 68cea3e

Please sign in to comment.
You can’t perform that action at this time.