mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-29 05:22:30 +02:00
test: Add FeeFilterRounder test
This commit is contained in:
parent
5f72ddb7ee
commit
fabf3d64ff
@ -231,6 +231,7 @@ BITCOIN_TESTS =\
|
|||||||
test/net_tests.cpp \
|
test/net_tests.cpp \
|
||||||
test/netbase_tests.cpp \
|
test/netbase_tests.cpp \
|
||||||
test/pmt_tests.cpp \
|
test/pmt_tests.cpp \
|
||||||
|
test/policy_fee_tests.cpp \
|
||||||
test/policyestimator_tests.cpp \
|
test/policyestimator_tests.cpp \
|
||||||
test/pow_tests.cpp \
|
test/pow_tests.cpp \
|
||||||
test/prevector_tests.cpp \
|
test/prevector_tests.cpp \
|
||||||
|
34
src/test/policy_fee_tests.cpp
Normal file
34
src/test/policy_fee_tests.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// Copyright (c) 2020 The Bitcoin Core developers
|
||||||
|
// Distributed under the MIT software license, see the accompanying
|
||||||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
#include <amount.h>
|
||||||
|
#include <policy/fees.h>
|
||||||
|
|
||||||
|
#include <test/util/setup_common.h>
|
||||||
|
|
||||||
|
#include <boost/test/unit_test.hpp>
|
||||||
|
|
||||||
|
BOOST_FIXTURE_TEST_SUITE(policy_fee_tests, BasicTestingSetup)
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(FeeRounder)
|
||||||
|
{
|
||||||
|
FeeFilterRounder fee_rounder{CFeeRate{1000}};
|
||||||
|
|
||||||
|
// check that 1000 rounds to 974 or 1071
|
||||||
|
std::set<CAmount> results;
|
||||||
|
while (results.size() < 2) {
|
||||||
|
results.emplace(fee_rounder.round(1000));
|
||||||
|
}
|
||||||
|
BOOST_CHECK_EQUAL(*results.begin(), 974);
|
||||||
|
BOOST_CHECK_EQUAL(*++results.begin(), 1071);
|
||||||
|
|
||||||
|
// check that negative amounts rounds to 0
|
||||||
|
BOOST_CHECK_EQUAL(fee_rounder.round(-0), 0);
|
||||||
|
BOOST_CHECK_EQUAL(fee_rounder.round(-1), 0);
|
||||||
|
|
||||||
|
// check that MAX_MONEY rounds to 9170997
|
||||||
|
BOOST_CHECK_EQUAL(fee_rounder.round(MAX_MONEY), 9170997);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_SUITE_END()
|
Loading…
Reference in New Issue
Block a user