Skip to content

Commit 4af4432

Browse files
Add unit tests for CPrivateSend::IsCollateralAmount (#3310)
* add privatesend collateral tests Signed-off-by: Pasta <pasta@dashboost.org> * move privatesend_tests.cpp in Makefile.test.include Signed-off-by: Pasta <pasta@dashboost.org>
1 parent e1fc378 commit 4af4432

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

src/Makefile.test.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ BITCOIN_TESTS =\
6868
test/policyestimator_tests.cpp \
6969
test/pow_tests.cpp \
7070
test/prevector_tests.cpp \
71+
test/privatesend_tests.cpp \
7172
test/raii_event_tests.cpp \
7273
test/random_tests.cpp \
7374
test/ratecheck_tests.cpp \

src/test/privatesend_tests.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) 2020 The Dash Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#include "test/test_dash.h"
6+
7+
#include "amount.h"
8+
#include "privatesend/privatesend.h"
9+
10+
#include <boost/test/unit_test.hpp>
11+
12+
BOOST_FIXTURE_TEST_SUITE(privatesend_tests, BasicTestingSetup)
13+
14+
BOOST_AUTO_TEST_CASE(ps_collatoral_tests)
15+
{
16+
// Good collateral values
17+
BOOST_CHECK(CPrivateSend::IsCollateralAmount(0.00010000 * COIN));
18+
BOOST_CHECK(CPrivateSend::IsCollateralAmount(0.00012345 * COIN));
19+
BOOST_CHECK(CPrivateSend::IsCollateralAmount(0.00032123 * COIN));
20+
BOOST_CHECK(CPrivateSend::IsCollateralAmount(0.00019000 * COIN));
21+
22+
// Bad collateral values
23+
BOOST_CHECK(!CPrivateSend::IsCollateralAmount(0.00009999 * COIN));
24+
BOOST_CHECK(!CPrivateSend::IsCollateralAmount(0.00040001 * COIN));
25+
BOOST_CHECK(!CPrivateSend::IsCollateralAmount(0.00100000 * COIN));
26+
BOOST_CHECK(!CPrivateSend::IsCollateralAmount(0.00100001 * COIN));
27+
}
28+
29+
BOOST_AUTO_TEST_SUITE_END()

src/test/test_dash.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "evo/deterministicmns.h"
2727
#include "evo/cbtx.h"
2828
#include "llmq/quorums_init.h"
29+
#include "privatesend/privatesend.h"
2930

3031
#include <memory>
3132

@@ -57,6 +58,7 @@ BasicTestingSetup::BasicTestingSetup(const std::string& chainName)
5758
SetupNetworking();
5859
InitSignatureCache();
5960
InitScriptExecutionCache();
61+
CPrivateSend::InitStandardDenominations();
6062
fPrintToDebugLog = false; // don't want to write to debug.log file
6163
fCheckBlockIndex = true;
6264
SelectParams(chainName);

0 commit comments

Comments
 (0)