mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-05 10:17:30 -05:00
f47dda2c58
-BEGIN VERIFY SCRIPT- ./contrib/devtools/copyright_header.py update ./ -END VERIFY SCRIPT- Commits of previous years: * 2020:fa0074e2d8
* 2019:aaaaad6ac9
34 lines
977 B
C++
34 lines
977 B
C++
// Copyright (c) 2020-2021 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 <consensus/amount.h>
|
|
#include <policy/fees.h>
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
#include <set>
|
|
|
|
BOOST_AUTO_TEST_SUITE(policy_fee_tests)
|
|
|
|
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()
|