diff options
author | MarcoFalke <falke.marco@gmail.com> | 2020-06-07 13:55:08 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2020-06-19 09:26:59 -0400 |
commit | fabf3d64ff2bd14f762810316144bb9fd69c517c (patch) | |
tree | ab606ee3b1cbcb112d4c17d9337a6fbf2bde5d88 /src/test/policy_fee_tests.cpp | |
parent | 5f72ddb7ee4cc177de31f43c69390ee72687222a (diff) |
test: Add FeeFilterRounder test
Diffstat (limited to 'src/test/policy_fee_tests.cpp')
-rw-r--r-- | src/test/policy_fee_tests.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/test/policy_fee_tests.cpp b/src/test/policy_fee_tests.cpp new file mode 100644 index 0000000000..6d8872b11e --- /dev/null +++ b/src/test/policy_fee_tests.cpp @@ -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() |