Skip to content

Commit

Permalink
Add unit test for budget value.
Browse files Browse the repository at this point in the history
Prevent any future issues with calculated budget value by adding a unit test.
  • Loading branch information
presstab authored and Fuzzbawls committed May 2, 2018
1 parent 9ee7d98 commit 43f6f1b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
31 changes: 31 additions & 0 deletions src/test/budget_tests.cpp
Original file line number Diff line number Diff line change
@@ -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 43f6f1b

Please sign in to comment.