xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
test
rpc
ValidatorInfo_test.cpp
1
// Copyright (c) 2020 Dev Null Productions
2
3
#include <test/jtx/Env.h>
4
#include <test/jtx/envconfig.h>
5
6
#include <xrpld/core/Config.h>
7
8
#include <xrpl/beast/unit_test/suite.h>
9
#include <xrpl/config/Constants.h>
10
#include <xrpl/protocol/jss.h>
11
12
#include <
memory
>
13
#include <
string
>
14
#include <
vector
>
15
16
namespace
xrpl::test
{
17
18
class
ValidatorInfo_test
:
public
beast::unit_test::Suite
19
{
20
public
:
21
void
22
testErrors
()
23
{
24
testcase
(
"Errors"
);
25
26
using namespace
jtx
;
27
{
28
Env
env(*
this
);
29
auto
const
info = env.
rpc
(
"validator_info"
);
30
BEAST_EXPECT(info[jss::result][jss::error_message] ==
"not a validator"
);
31
}
32
}
33
34
void
35
testPrivileges
()
36
{
37
using namespace
test::jtx
;
38
Env
env{*
this
,
envconfig
(
noAdmin
)};
39
env.
setRetries
(0);
40
auto
const
info = env.
rpc
(
"validator_info"
)[jss::result];
41
BEAST_EXPECT(info.isNull());
42
}
43
44
void
45
testLookup
()
46
{
47
testcase
(
"Lookup"
);
48
49
using namespace
jtx
;
50
std::vector<std::string>
const
tokenBlob = {
51
" eyJ2YWxpZGF0aW9uX3NlY3JldF9rZXkiOiI5ZWQ0NWY4NjYyNDFjYzE4YTI3NDdiNT\n"
,
52
" \tQzODdjMDYyNTkwNzk3MmY0ZTcxOTAyMzFmYWE5Mzc0NTdmYTlkYWY2IiwibWFuaWZl \n"
,
53
"\tc3QiOiJKQUFBQUFGeEllMUZ0d21pbXZHdEgyaUNjTUpxQzlnVkZLaWxHZncxL3ZDeE\n"
,
54
"\t hYWExwbGMyR25NaEFrRTFhZ3FYeEJ3RHdEYklENk9NU1l1TTBGREFscEFnTms4U0tG\t \t\n"
,
55
"bjdNTzJmZGtjd1JRSWhBT25ndTlzQUtxWFlvdUorbDJWMFcrc0FPa1ZCK1pSUzZQU2\n"
,
56
"hsSkFmVXNYZkFpQnNWSkdlc2FhZE9KYy9hQVpva1MxdnltR21WcmxIUEtXWDNZeXd1\n"
,
57
"NmluOEhBU1FLUHVnQkQ2N2tNYVJGR3ZtcEFUSGxHS0pkdkRGbFdQWXk1QXFEZWRGdj\n"
,
58
"VUSmEydzBpMjFlcTNNWXl3TFZKWm5GT3I3QzBrdzJBaVR6U0NqSXpkaXRROD0ifQ==\n"
,
59
};
60
61
std::string
const
masterKey =
"nHBt9fsb4849WmZiCds4r5TXyBeQjqnH5kzPtqgMAQMgi39YZRPa"
;
62
std::string
const
ephemeralKey =
"n9KsDYGKhABVc4wK5u3MnVhgPinyJimyKGpr9VJYuBaY8EnJXR2x"
;
63
std::string
const
manifest =
64
"JAAAAAFxIe1FtwmimvGtH2iCcMJqC9gVFKilGfw1/"
65
"vCxHXXLplc2GnMhAkE1agqXxBwDwDbID6OMSYuM0FDAlpAgNk8SKFn7MO2fdkcwRQI"
66
"hAOngu9sAKqXYouJ+l2V0W+sAOkVB+ZRS6PShlJAfUsXfAiBsVJGesaadOJc/"
67
"aAZokS1vymGmVrlHPKWX3Yywu6in8HASQKPugBD67kMaRFGvmpATHlGKJdvDFlWPYy"
68
"5AqDedFv5TJa2w0i21eq3MYywLVJZnFOr7C0kw2AiTzSCjIzditQ8="
;
69
70
Env
env{*
this
,
envconfig
([&tokenBlob](
std::unique_ptr<Config>
cfg) {
71
cfg->section(
Sections::kValidatorToken
).append(tokenBlob);
72
return
cfg;
73
})};
74
{
75
auto
const
info = env.
rpc
(
"validator_info"
);
76
BEAST_EXPECT(info[jss::result][jss::status] ==
"success"
);
77
BEAST_EXPECT(info[jss::result][jss::seq] == 1);
78
BEAST_EXPECT(info[jss::result][jss::master_key] == masterKey);
79
BEAST_EXPECT(info[jss::result][jss::manifest] == manifest);
80
BEAST_EXPECT(info[jss::result][jss::ephemeral_key] == ephemeralKey);
81
}
82
}
83
84
void
85
run
()
override
86
{
87
testErrors
();
88
testPrivileges
();
89
testLookup
();
90
}
91
};
92
93
BEAST_DEFINE_TESTSUITE
(ValidatorInfo,
rpc
,
xrpl
);
94
}
// namespace xrpl::test
std::string
beast::unit_test::Suite
A testsuite class.
Definition
suite.h:52
beast::unit_test::Suite::testcase
TestcaseT testcase
Memberspace for declaring test cases.
Definition
suite.h:155
xrpl::test::ValidatorInfo_test
Definition
ValidatorInfo_test.cpp:19
xrpl::test::ValidatorInfo_test::testLookup
void testLookup()
Definition
ValidatorInfo_test.cpp:45
xrpl::test::ValidatorInfo_test::testErrors
void testErrors()
Definition
ValidatorInfo_test.cpp:22
xrpl::test::ValidatorInfo_test::testPrivileges
void testPrivileges()
Definition
ValidatorInfo_test.cpp:35
xrpl::test::ValidatorInfo_test::run
void run() override
Runs the suite.
Definition
ValidatorInfo_test.cpp:85
xrpl::test::jtx::Env
A transaction testing environment.
Definition
Env.h:161
xrpl::test::jtx::Env::setRetries
void setRetries(unsigned r=5)
Definition
Env.h:612
xrpl::test::jtx::Env::rpc
json::Value rpc(unsigned apiVersion, std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
Definition
Env.h:1058
memory
xrpl::rpc
API version numbers used in later API versions.
Definition
ApiVersion.h:36
xrpl::test::jtx
Definition
Oracle_test.cpp:34
xrpl::test::jtx::envconfig
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition
envconfig.h:38
xrpl::test::jtx::noAdmin
std::unique_ptr< Config > noAdmin(std::unique_ptr< Config >)
adjust config so no admin ports are enabled
Definition
envconfig.cpp:75
xrpl::test
Definition
STLedgerEntry.h:21
xrpl::test::BEAST_DEFINE_TESTSUITE
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
string
xrpl::Sections::kValidatorToken
static constexpr auto kValidatorToken
Definition
Constants.h:73
std::unique_ptr
vector
Generated by
1.17.0