xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
test
rpc
ManifestRPC_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
16
namespace
xrpl::test
{
17
18
class
ManifestRPC_test
:
public
beast::unit_test::Suite
19
{
20
public
:
21
void
22
testErrors
()
23
{
24
testcase
(
"Errors"
);
25
26
using namespace
jtx
;
27
Env
env(*
this
);
28
{
29
// manifest with no public key
30
auto
const
info = env.
rpc
(
"json"
,
"manifest"
,
"{ }"
);
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] ==
"Missing field 'public_key'."
);
34
}
35
{
36
// manifest with malformed public key
37
auto
const
info = env.
rpc
(
38
"json"
,
39
"manifest"
,
40
"{ \"public_key\": "
41
"\"abcdef12345\"}"
);
42
BEAST_EXPECT(info[jss::result][jss::error] ==
"invalidParams"
);
43
BEAST_EXPECT(info[jss::result][jss::error_code] ==
RpcInvalidParams
);
44
BEAST_EXPECT(info[jss::result][jss::error_message] ==
"Invalid parameters."
);
45
}
46
}
47
48
void
49
testLookup
()
50
{
51
testcase
(
"Lookup"
);
52
53
using namespace
jtx
;
54
std::string
const
key =
"n949f75evCHwgyP4fPVgaHqNHxUVN15PsJEZ3B3HnXPcPjcZAoy7"
;
55
Env
env{*
this
,
envconfig
([&key](
std::unique_ptr<Config>
cfg) {
56
cfg->section(
Sections::kValidators
).append(key);
57
return
cfg;
58
})};
59
{
60
auto
const
info = env.
rpc
(
61
"json"
,
62
"manifest"
,
63
"{ \"public_key\": "
64
"\""
+
65
key +
"\"}"
);
66
BEAST_EXPECT(info[jss::result][jss::requested] == key);
67
BEAST_EXPECT(info[jss::result][jss::status] ==
"success"
);
68
}
69
}
70
71
void
72
run
()
override
73
{
74
testErrors
();
75
testLookup
();
76
}
77
};
78
79
BEAST_DEFINE_TESTSUITE
(ManifestRPC,
rpc
,
xrpl
);
80
}
// 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::ManifestRPC_test
Definition
ManifestRPC_test.cpp:19
xrpl::test::ManifestRPC_test::run
void run() override
Runs the suite.
Definition
ManifestRPC_test.cpp:72
xrpl::test::ManifestRPC_test::testErrors
void testErrors()
Definition
ManifestRPC_test.cpp:22
xrpl::test::ManifestRPC_test::testLookup
void testLookup()
Definition
ManifestRPC_test.cpp:49
xrpl::test::jtx::Env
A transaction testing environment.
Definition
Env.h:161
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
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::kValidators
static constexpr auto kValidators
Definition
Constants.h:74
std::unique_ptr
Generated by
1.17.0