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#include <xrpl/basics/BasicConfig.h>
22
23namespace ripple {
24namespace test {
25
27{
28 void
30 {
31 FeeSetup const defaultSetup;
32 {
33 // defaults
34 Section config;
35 auto setup = setup_FeeVote(config);
36 BEAST_EXPECT(setup.reference_fee == defaultSetup.reference_fee);
37 BEAST_EXPECT(setup.account_reserve == defaultSetup.account_reserve);
38 BEAST_EXPECT(setup.owner_reserve == defaultSetup.owner_reserve);
39 }
40 {
41 Section config;
42 config.append(
43 {"reference_fee = 50",
44 "account_reserve = 1234567",
45 "owner_reserve = 1234"});
46 auto setup = setup_FeeVote(config);
47 BEAST_EXPECT(setup.reference_fee == 50);
48 BEAST_EXPECT(setup.account_reserve == 1234567);
49 BEAST_EXPECT(setup.owner_reserve == 1234);
50 }
51 {
52 Section config;
53 config.append(
54 {"reference_fee = blah",
55 "account_reserve = yada",
56 "owner_reserve = foo"});
57 // Illegal values are ignored, and the defaults left unchanged
58 auto setup = setup_FeeVote(config);
59 BEAST_EXPECT(setup.reference_fee == defaultSetup.reference_fee);
60 BEAST_EXPECT(setup.account_reserve == defaultSetup.account_reserve);
61 BEAST_EXPECT(setup.owner_reserve == defaultSetup.owner_reserve);
62 }
63 {
64 Section config;
65 config.append(
66 {"reference_fee = -50",
67 "account_reserve = -1234567",
68 "owner_reserve = -1234"});
69 // Illegal values are ignored, and the defaults left unchanged
70 auto setup = setup_FeeVote(config);
71 BEAST_EXPECT(setup.reference_fee == defaultSetup.reference_fee);
72 BEAST_EXPECT(
73 setup.account_reserve == static_cast<std::uint32_t>(-1234567));
74 BEAST_EXPECT(
75 setup.owner_reserve == static_cast<std::uint32_t>(-1234));
76 }
77 {
78 const auto big64 = std::to_string(
79 static_cast<std::uint64_t>(
81 1);
82 Section config;
83 config.append(
84 {"reference_fee = " + big64,
85 "account_reserve = " + big64,
86 "owner_reserve = " + big64});
87 // Illegal values are ignored, and the defaults left unchanged
88 auto setup = setup_FeeVote(config);
89 BEAST_EXPECT(setup.reference_fee == defaultSetup.reference_fee);
90 BEAST_EXPECT(setup.account_reserve == defaultSetup.account_reserve);
91 BEAST_EXPECT(setup.owner_reserve == defaultSetup.owner_reserve);
92 }
93 }
94
95 void
96 run() override
97 {
98 testSetup();
99 }
100};
101
102BEAST_DEFINE_TESTSUITE(FeeVote, server, ripple);
103
104} // namespace test
105} // namespace ripple
A testsuite class.
Definition: suite.h:55
Manager to process fee votes.
Definition: FeeVote.h:31
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.
Definition: BasicConfig.cpp:47
void run() override
Runs the suite.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
FeeSetup setup_FeeVote(Section const &section)
Definition: Config.cpp:1091
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)