Bitcoin Core  22.99.0
P2P Digital Currency
policy_fee_tests.cpp
Go to the documentation of this file.
1 // Copyright (c) 2020 The Bitcoin 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 <amount.h>
6 #include <policy/fees.h>
7 
8 #include <boost/test/unit_test.hpp>
9 
10 #include <set>
11 
12 BOOST_AUTO_TEST_SUITE(policy_fee_tests)
13 
15 {
16  FeeFilterRounder fee_rounder{CFeeRate{1000}};
17 
18  // check that 1000 rounds to 974 or 1071
19  std::set<CAmount> results;
20  while (results.size() < 2) {
21  results.emplace(fee_rounder.round(1000));
22  }
23  BOOST_CHECK_EQUAL(*results.begin(), 974);
24  BOOST_CHECK_EQUAL(*++results.begin(), 1071);
25 
26  // check that negative amounts rounds to 0
27  BOOST_CHECK_EQUAL(fee_rounder.round(-0), 0);
28  BOOST_CHECK_EQUAL(fee_rounder.round(-1), 0);
29 
30  // check that MAX_MONEY rounds to 9170997
31  BOOST_CHECK_EQUAL(fee_rounder.round(MAX_MONEY), 9170997);
32 }
33 
BOOST_AUTO_TEST_SUITE
BOOST_AUTO_TEST_SUITE(cuckoocache_tests)
Test Suite for CuckooCache.
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(FeeRounder)
Definition: policy_fee_tests.cpp:14
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
CFeeRate
Fee rate in satoshis per kilobyte: CAmount / kB.
Definition: feerate.h:29
FeeFilterRounder
Definition: fees.h:272
fees.h
MAX_MONEY
static const CAmount MAX_MONEY
No amount larger than this (in satoshi) is valid.
Definition: amount.h:25
amount.h
BOOST_CHECK_EQUAL
#define BOOST_CHECK_EQUAL(v1, v2)
Definition: object.cpp:18