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