rippled
Loading...
Searching...
No Matches
LoadFeeTrack_test.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#include <xrpld/app/misc/LoadFeeTrack.h>
21#include <xrpld/core/Config.h>
22
23#include <xrpl/beast/unit_test.h>
24#include <xrpl/ledger/ReadView.h>
25
26namespace ripple {
27
29{
30public:
31 void
32 run() override
33 {
34 Config d; // get a default configuration object
36 {
37 Fees const fees = [&]() {
38 Fees f;
40 f.reserve = 200 * DROPS_PER_XRP;
41 f.increment = 50 * DROPS_PER_XRP;
42 return f;
43 }();
44
45 BEAST_EXPECT(
46 scaleFeeLoad(XRPAmount{0}, l, fees, false) == XRPAmount{0});
47 BEAST_EXPECT(
48 scaleFeeLoad(XRPAmount{10000}, l, fees, false) ==
49 XRPAmount{10000});
50 BEAST_EXPECT(
51 scaleFeeLoad(XRPAmount{1}, l, fees, false) == XRPAmount{1});
52 }
53 {
54 Fees const fees = [&]() {
55 Fees f;
56 f.base = d.FEES.reference_fee * 10;
57 f.reserve = 200 * DROPS_PER_XRP;
58 f.increment = 50 * DROPS_PER_XRP;
59 return f;
60 }();
61
62 BEAST_EXPECT(
63 scaleFeeLoad(XRPAmount{0}, l, fees, false) == XRPAmount{0});
64 BEAST_EXPECT(
65 scaleFeeLoad(XRPAmount{10000}, l, fees, false) ==
66 XRPAmount{10000});
67 BEAST_EXPECT(
68 scaleFeeLoad(XRPAmount{1}, l, fees, false) == XRPAmount{1});
69 }
70 {
71 Fees const fees = [&]() {
72 Fees f;
74 f.reserve = 200 * DROPS_PER_XRP;
75 f.increment = 50 * DROPS_PER_XRP;
76 return f;
77 }();
78
79 BEAST_EXPECT(
80 scaleFeeLoad(XRPAmount{0}, l, fees, false) == XRPAmount{0});
81 BEAST_EXPECT(
82 scaleFeeLoad(XRPAmount{10000}, l, fees, false) ==
83 XRPAmount{10000});
84 BEAST_EXPECT(
85 scaleFeeLoad(XRPAmount{1}, l, fees, false) == XRPAmount{1});
86 }
87 }
88};
89
90BEAST_DEFINE_TESTSUITE(LoadFeeTrack, app, ripple);
91
92} // namespace ripple
A testsuite class.
Definition suite.h:55
FeeSetup FEES
Definition Config.h:204
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:25
XRPAmount scaleFeeLoad(XRPAmount fee, LoadFeeTrack const &feeTrack, Fees const &fees, bool bUnlimited)
constexpr XRPAmount DROPS_PER_XRP
Number of drops per 1 XRP.
Definition XRPAmount.h:259
XRPAmount reference_fee
The cost of a reference transaction in drops.
Definition Config.h:68
Reflects the fee settings for a particular ledger.
XRPAmount base
XRPAmount increment
XRPAmount reserve