Skip to content

Commit

Permalink
Merge #593: 3.1.0.2 backport
Browse files Browse the repository at this point in the history
43f6f1b Add unit test for budget value. (presstab)
9ee7d98 Update protocol to 70914. (presstab)
ebc4527 [Budget] Fix wrong budget amount (Mrs-X)

Tree-SHA512: 6d813ee5e9cc548ffd8b3c816f669a9b79a6b8118de73941fd3fc6d7be46ae2dbfa935d94d1b62c32c1700165ad5a637f87eeaa8cd36927d4d281193b9c84ada
  • Loading branch information
Fuzzbawls committed May 2, 2018
2 parents 74f15ac + 43f6f1b commit ab04943
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 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
2 changes: 1 addition & 1 deletion src/masternode-budget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ CAmount CBudgetManager::GetTotalBudget(int nHeight)
} else if (nHeight <= 647999 && nHeight >= 604800) {
nSubsidy = 10 * COIN;
} else if (nHeight >= Params().Zerocoin_Block_V2_Start()) {
nSubsidy = 6 * COIN;
nSubsidy = 10 * COIN;
} else {
nSubsidy = 5 * COIN;
}
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()
4 changes: 2 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* network protocol versioning
*/

static const int PROTOCOL_VERSION = 70913;
static const int PROTOCOL_VERSION = 70914;

//! initial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209;
Expand All @@ -21,7 +21,7 @@ static const int GETHEADERS_VERSION = 70077;

//! disconnect from peers older than this proto version
static const int MIN_PEER_PROTO_VERSION_BEFORE_ENFORCEMENT = 70912;
static const int MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT = 70913;
static const int MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT = 70914;

//! masternodes older than this proto version use old strMessage format for mnannounce
static const int MIN_PEER_MNANNOUNCE = 70913;
Expand Down

0 comments on commit ab04943

Please sign in to comment.