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/ErrorCodes.h>
11
#include <xrpl/protocol/jss.h>
12
13
#include <
memory
>
14
#include <
string
>
15
#include <
vector
>
16
17
namespace
xrpl::test
{
18
19
class
ValidatorInfo_test
:
public
beast::unit_test::Suite
20
{
21
public
:
22
void
23
testErrors
()
24
{
25
testcase
(
"Errors"
);
26
27
using namespace
jtx
;
28
{
29
Env
env(*
this
);
30
auto
const
info = env.
rpc
(
"validator_info"
);
31
BEAST_EXPECT(info[jss::result][jss::error] ==
"invalidParams"
);
32
BEAST_EXPECT(info[jss::result][jss::error_code] ==
RpcInvalidParams
);
33
BEAST_EXPECT(info[jss::result][jss::error_message] ==
"not a validator"
);
34
}
35
}
36
37
void
38
testPrivileges
()
39
{
40
using namespace
test::jtx
;
41
Env
env{*
this
,
envconfig
(
noAdmin
)};
42
env.
setRetries
(0);
43
auto
const
info = env.
rpc
(
"validator_info"
)[jss::result];
44
BEAST_EXPECT(info.isNull());
45
}
46
47
void
48
testLookup
()
49
{
50
testcase
(
"Lookup"
);
51
52
using namespace
jtx
;
53
std::vector<std::string>
const
tokenBlob = {
54
" eyJ2YWxpZGF0aW9uX3NlY3JldF9rZXkiOiI5ZWQ0NWY4NjYyNDFjYzE4YTI3NDdiNT\n"
,
55
" \tQzODdjMDYyNTkwNzk3MmY0ZTcxOTAyMzFmYWE5Mzc0NTdmYTlkYWY2IiwibWFuaWZl \n"
,
56
"\tc3QiOiJKQUFBQUFGeEllMUZ0d21pbXZHdEgyaUNjTUpxQzlnVkZLaWxHZncxL3ZDeE\n"
,
57
"\t hYWExwbGMyR25NaEFrRTFhZ3FYeEJ3RHdEYklENk9NU1l1TTBGREFscEFnTms4U0tG\t \t\n"
,
58
"bjdNTzJmZGtjd1JRSWhBT25ndTlzQUtxWFlvdUorbDJWMFcrc0FPa1ZCK1pSUzZQU2\n"
,
59
"hsSkFmVXNYZkFpQnNWSkdlc2FhZE9KYy9hQVpva1MxdnltR21WcmxIUEtXWDNZeXd1\n"
,
60
"NmluOEhBU1FLUHVnQkQ2N2tNYVJGR3ZtcEFUSGxHS0pkdkRGbFdQWXk1QXFEZWRGdj\n"
,
61
"VUSmEydzBpMjFlcTNNWXl3TFZKWm5GT3I3QzBrdzJBaVR6U0NqSXpkaXRROD0ifQ==\n"
,
62
};
63
64
std::string
const
masterKey =
"nHBt9fsb4849WmZiCds4r5TXyBeQjqnH5kzPtqgMAQMgi39YZRPa"
;
65
std::string
const
ephemeralKey =
"n9KsDYGKhABVc4wK5u3MnVhgPinyJimyKGpr9VJYuBaY8EnJXR2x"
;
66
std::string
const
manifest =
67
"JAAAAAFxIe1FtwmimvGtH2iCcMJqC9gVFKilGfw1/"
68
"vCxHXXLplc2GnMhAkE1agqXxBwDwDbID6OMSYuM0FDAlpAgNk8SKFn7MO2fdkcwRQI"
69
"hAOngu9sAKqXYouJ+l2V0W+sAOkVB+ZRS6PShlJAfUsXfAiBsVJGesaadOJc/"
70
"aAZokS1vymGmVrlHPKWX3Yywu6in8HASQKPugBD67kMaRFGvmpATHlGKJdvDFlWPYy"
71
"5AqDedFv5TJa2w0i21eq3MYywLVJZnFOr7C0kw2AiTzSCjIzditQ8="
;
72
73
Env
env{*
this
,
envconfig
([&tokenBlob](
std::unique_ptr<Config>
cfg) {
74
cfg->section(
Sections::kValidatorToken
).append(tokenBlob);
75
return
cfg;
76
})};
77
{
78
auto
const
info = env.
rpc
(
"validator_info"
);
79
BEAST_EXPECT(info[jss::result][jss::status] ==
"success"
);
80
BEAST_EXPECT(info[jss::result][jss::seq] == 1);
81
BEAST_EXPECT(info[jss::result][jss::master_key] == masterKey);
82
BEAST_EXPECT(info[jss::result][jss::manifest] == manifest);
83
BEAST_EXPECT(info[jss::result][jss::ephemeral_key] == ephemeralKey);
84
}
85
}
86
87
void
88
run
()
override
89
{
90
testErrors
();
91
testPrivileges
();
92
testLookup
();
93
}
94
};
95
96
BEAST_DEFINE_TESTSUITE
(ValidatorInfo,
rpc
,
xrpl
);
97
}
// 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:20
xrpl::test::ValidatorInfo_test::testLookup
void testLookup()
Definition
ValidatorInfo_test.cpp:48
xrpl::test::ValidatorInfo_test::testErrors
void testErrors()
Definition
ValidatorInfo_test.cpp:23
xrpl::test::ValidatorInfo_test::testPrivileges
void testPrivileges()
Definition
ValidatorInfo_test.cpp:38
xrpl::test::ValidatorInfo_test::run
void run() override
Runs the suite.
Definition
ValidatorInfo_test.cpp:88
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
The api_version numbers this server serves.
Definition
ApiVersion.h:26
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:76
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
xrpl::RpcInvalidParams
@ RpcInvalidParams
Definition
ErrorCodes.h:67
string
xrpl::Sections::kValidatorToken
static constexpr auto kValidatorToken
Definition
Constants.h:73
std::unique_ptr
vector
Generated by
1.17.0