rippled
Loading...
Searching...
No Matches
FeeVote_test.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2019 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 <test/jtx.h>
21
22#include <xrpl/basics/BasicConfig.h>
23
24namespace ripple {
25namespace test {
26
28{
29 void
31 {
32 FeeSetup const defaultSetup;
33 {
34 // defaults
35 Section config;
36 auto setup = setup_FeeVote(config);
37 BEAST_EXPECT(setup.reference_fee == defaultSetup.reference_fee);
38 BEAST_EXPECT(setup.account_reserve == defaultSetup.account_reserve);
39 BEAST_EXPECT(setup.owner_reserve == defaultSetup.owner_reserve);
40 }
41 {
42 Section config;
43 config.append(
44 {"reference_fee = 50",
45 "account_reserve = 1234567",
46 "owner_reserve = 1234"});
47 auto setup = setup_FeeVote(config);
48 BEAST_EXPECT(setup.reference_fee == 50);
49 BEAST_EXPECT(setup.account_reserve == 1234567);
50 BEAST_EXPECT(setup.owner_reserve == 1234);
51 }
52 {
53 Section config;
54 config.append(
55 {"reference_fee = blah",
56 "account_reserve = yada",
57 "owner_reserve = foo"});
58 // Illegal values are ignored, and the defaults left unchanged
59 auto setup = setup_FeeVote(config);
60 BEAST_EXPECT(setup.reference_fee == defaultSetup.reference_fee);
61 BEAST_EXPECT(setup.account_reserve == defaultSetup.account_reserve);
62 BEAST_EXPECT(setup.owner_reserve == defaultSetup.owner_reserve);
63 }
64 {
65 Section config;
66 config.append(
67 {"reference_fee = -50",
68 "account_reserve = -1234567",
69 "owner_reserve = -1234"});
70 // Illegal values are ignored, and the defaults left unchanged
71 auto setup = setup_FeeVote(config);
72 BEAST_EXPECT(setup.reference_fee == defaultSetup.reference_fee);
73 BEAST_EXPECT(
74 setup.account_reserve == static_cast<std::uint32_t>(-1234567));
75 BEAST_EXPECT(
76 setup.owner_reserve == static_cast<std::uint32_t>(-1234));
77 }
78 {
79 auto const big64 = std::to_string(
80 static_cast<std::uint64_t>(
82 1);
83 Section config;
84 config.append(
85 {"reference_fee = " + big64,
86 "account_reserve = " + big64,
87 "owner_reserve = " + big64});
88 // Illegal values are ignored, and the defaults left unchanged
89 auto setup = setup_FeeVote(config);
90 BEAST_EXPECT(setup.reference_fee == defaultSetup.reference_fee);
91 BEAST_EXPECT(setup.account_reserve == defaultSetup.account_reserve);
92 BEAST_EXPECT(setup.owner_reserve == defaultSetup.owner_reserve);
93 }
94 }
95
96 void
97 run() override
98 {
99 testSetup();
100 }
101};
102
103BEAST_DEFINE_TESTSUITE(FeeVote, app, ripple);
104
105} // namespace test
106} // namespace ripple
A testsuite class.
Definition suite.h:55
Manager to process fee votes.
Definition FeeVote.h:32
Holds a collection of configuration values.
Definition BasicConfig.h:45
void append(std::vector< std::string > const &lines)
Append a set of lines to this section.
void run() override
Runs the suite.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
FeeSetup setup_FeeVote(Section const &section)
Definition Config.cpp:1129
Fee schedule for startup / standalone, and to vote for.
Definition Config.h:66
XRPAmount reference_fee
The cost of a reference transaction in drops.
Definition Config.h:68
XRPAmount owner_reserve
The per-owned item reserve requirement in drops.
Definition Config.h:74
XRPAmount account_reserve
The account reserve requirement in drops.
Definition Config.h:71
T to_string(T... args)