Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
test
feerounder_tests.cpp
Go to the documentation of this file.
1
// Copyright (c) 2020-present 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 <
consensus/amount.h
>
6
#include <
policy/fees/block_policy_estimator.h
>
7
8
#include <boost/test/unit_test.hpp>
9
10
#include <set>
11
12
BOOST_AUTO_TEST_SUITE(fee_rounder_tests)
13
14
BOOST_AUTO_TEST_CASE
(FeeRounder)
15
{
16
FastRandomContext
rng{
/*fDeterministic=*/
true
};
17
FeeFilterRounder
fee_rounder{
CFeeRate
{1000}, rng};
18
19
// check that 1000 rounds to 974 or 1071
20
std::set<CAmount> results;
21
while
(results.size() < 2) {
22
results.emplace(fee_rounder.round(1000));
23
}
24
BOOST_CHECK_EQUAL
(*results.begin(), 974);
25
BOOST_CHECK_EQUAL
(*++results.begin(), 1071);
26
27
// check that negative amounts rounds to 0
28
BOOST_CHECK_EQUAL
(fee_rounder.
round
(-0), 0);
29
BOOST_CHECK_EQUAL
(fee_rounder.
round
(-1), 0);
30
31
// check that MAX_MONEY rounds to 9170997
32
BOOST_CHECK_EQUAL
(fee_rounder.
round
(
MAX_MONEY
), 9170997);
33
}
34
35
BOOST_AUTO_TEST_SUITE_END
()
amount.h
MAX_MONEY
static constexpr CAmount MAX_MONEY
No amount larger than this (in satoshi) is valid.
Definition
amount.h:26
block_policy_estimator.h
CFeeRate
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
Definition
feerate.h:32
FastRandomContext
Fast randomness source.
Definition
random.h:386
FeeFilterRounder
Definition
block_policy_estimator.h:325
FeeFilterRounder::round
CAmount round(CAmount currentMinFee) EXCLUSIVE_LOCKS_REQUIRED(!m_insecure_rand_mutex)
Quantize a minimum fee for privacy purpose before broadcast.
Definition
block_policy_estimator.cpp:1109
BOOST_AUTO_TEST_SUITE_END
BOOST_AUTO_TEST_SUITE_END()
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(ipc_tests)
Definition
ipc_tests.cpp:13
BOOST_CHECK_EQUAL
#define BOOST_CHECK_EQUAL(v1, v2)
Definition
object.cpp:17
Generated on
for Bitcoin Core by
1.17.0