rippled
Loading...
Searching...
No Matches
LoadFeeTrack_test.cpp
1#include <xrpld/app/misc/LoadFeeTrack.h>
2#include <xrpld/core/Config.h>
3
4#include <xrpl/beast/unit_test.h>
5#include <xrpl/ledger/ReadView.h>
6
7namespace xrpl {
8
10{
11public:
12 void
13 run() override
14 {
15 Config d; // get a default configuration object
17 {
18 Fees const fees = [&]() {
19 Fees f;
21 f.reserve = 200 * DROPS_PER_XRP;
22 f.increment = 50 * DROPS_PER_XRP;
23 return f;
24 }();
25
26 BEAST_EXPECT(scaleFeeLoad(XRPAmount{0}, l, fees, false) == XRPAmount{0});
27 BEAST_EXPECT(scaleFeeLoad(XRPAmount{10000}, l, fees, false) == XRPAmount{10000});
28 BEAST_EXPECT(scaleFeeLoad(XRPAmount{1}, l, fees, false) == XRPAmount{1});
29 }
30 {
31 Fees const fees = [&]() {
32 Fees f;
33 f.base = d.FEES.reference_fee * 10;
34 f.reserve = 200 * DROPS_PER_XRP;
35 f.increment = 50 * DROPS_PER_XRP;
36 return f;
37 }();
38
39 BEAST_EXPECT(scaleFeeLoad(XRPAmount{0}, l, fees, false) == XRPAmount{0});
40 BEAST_EXPECT(scaleFeeLoad(XRPAmount{10000}, l, fees, false) == XRPAmount{10000});
41 BEAST_EXPECT(scaleFeeLoad(XRPAmount{1}, l, fees, false) == XRPAmount{1});
42 }
43 {
44 Fees const fees = [&]() {
45 Fees f;
47 f.reserve = 200 * DROPS_PER_XRP;
48 f.increment = 50 * DROPS_PER_XRP;
49 return f;
50 }();
51
52 BEAST_EXPECT(scaleFeeLoad(XRPAmount{0}, l, fees, false) == XRPAmount{0});
53 BEAST_EXPECT(scaleFeeLoad(XRPAmount{10000}, l, fees, false) == XRPAmount{10000});
54 BEAST_EXPECT(scaleFeeLoad(XRPAmount{1}, l, fees, false) == XRPAmount{1});
55 }
56 }
57};
58
59BEAST_DEFINE_TESTSUITE(LoadFeeTrack, app, xrpl);
60
61} // namespace xrpl
A testsuite class.
Definition suite.h:52
FeeSetup FEES
Definition Config.h:185
void run() override
Runs the suite.
Manages the current fee schedule.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
constexpr XRPAmount DROPS_PER_XRP
Number of drops per 1 XRP.
Definition XRPAmount.h:238
XRPAmount scaleFeeLoad(XRPAmount fee, LoadFeeTrack const &feeTrack, Fees const &fees, bool bUnlimited)
XRPAmount reference_fee
The cost of a reference transaction in drops.
Definition Config.h:49
Reflects the fee settings for a particular ledger.
XRPAmount reserve
XRPAmount increment
XRPAmount base