2020-06-07 13:55:08 -04:00
|
|
|
// 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.
|
|
|
|
|
2021-09-11 10:29:00 +08:00
|
|
|
#include <consensus/amount.h>
|
2020-06-07 13:55:08 -04:00
|
|
|
#include <policy/fees.h>
|
|
|
|
|
|
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
|
2021-05-26 20:34:42 +08:00
|
|
|
#include <set>
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_SUITE(policy_fee_tests)
|
2020-06-07 13:55:08 -04:00
|
|
|
|
|
|
|
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()
|