Skip to content

Commit 43f6f1b

Browse files
presstabFuzzbawls
authored andcommitted
Add unit test for budget value.
Prevent any future issues with calculated budget value by adding a unit test.
1 parent 9ee7d98 commit 43f6f1b

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/Makefile.test.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ BITCOIN_TESTS =\
4848
test/base32_tests.cpp \
4949
test/base58_tests.cpp \
5050
test/base64_tests.cpp \
51+
test/budget_tests.cpp \
5152
test/checkblock_tests.cpp \
5253
test/Checkpoints_tests.cpp \
5354
test/coins_tests.cpp \

src/test/budget_tests.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) 2018 The PIVX developers
2+
// Distributed under the MIT/X11 software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#include <boost/test/unit_test.hpp>
6+
#include <tinyformat.h>
7+
#include <utilmoneystr.h>
8+
#include "masternode-budget.h"
9+
10+
BOOST_AUTO_TEST_SUITE(budget_tests)
11+
12+
void CheckBudgetValue(int nHeight, std::string strNetwork, CAmount nExpectedValue)
13+
{
14+
CBudgetManager budget;
15+
CAmount nBudget = budget.GetTotalBudget(nHeight);
16+
std::string strError = strprintf("Budget is not as expected for %s. Result: %s, Expected: %s", strNetwork, FormatMoney(nBudget), FormatMoney(nExpectedValue));
17+
BOOST_CHECK_MESSAGE(nBudget == nExpectedValue, strError);
18+
}
19+
20+
BOOST_AUTO_TEST_CASE(budget_value)
21+
{
22+
SelectParams(CBaseChainParams::MAIN);
23+
int nHeightTest = Params().Zerocoin_Block_V2_Start() + 1;
24+
CheckBudgetValue(nHeightTest, "mainnet", 43200*COIN);
25+
26+
SelectParams(CBaseChainParams::TESTNET);
27+
nHeightTest = Params().Zerocoin_Block_V2_Start() + 1;
28+
CheckBudgetValue(nHeightTest, "testnet", 7300*COIN);
29+
}
30+
31+
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)