forked from namecoin/namecoin-core
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpolicy_fee_tests.cpp
41 lines (31 loc) · 1.34 KB
/
policy_fee_tests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// 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 <validation.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);
/* Doichain uses a different DEFAULT_MIN_RELAY_TX_FEE value than
upstream Bitcoin. Verify the expected rounding value for MAX_MONEY
(which is used as fee filter during IBD) also for that. */
FeeFilterRounder nmc_rounder{CFeeRate{DEFAULT_MIN_RELAY_TX_FEE}};
BOOST_CHECK_EQUAL(nmc_rounder.round(MAX_MONEY), 9452957);
}
BOOST_AUTO_TEST_SUITE_END()