rippled
Loading...
Searching...
No Matches
ManifestRPC_test.cpp
1// Copyright (c) 2020 Dev Null Productions
2
3#include <test/jtx.h>
4
5#include <xrpld/core/ConfigSections.h>
6
7#include <xrpl/beast/unit_test.h>
8#include <xrpl/protocol/jss.h>
9
10#include <string>
11
12namespace xrpl {
13namespace test {
14
16{
17public:
18 void
20 {
21 testcase("Errors");
22
23 using namespace jtx;
24 Env env(*this);
25 {
26 // manifest with no public key
27 auto const info = env.rpc("json", "manifest", "{ }");
28 BEAST_EXPECT(info[jss::result][jss::error_message] == "Missing field 'public_key'.");
29 }
30 {
31 // manifest with malformed public key
32 auto const info = env.rpc(
33 "json",
34 "manifest",
35 "{ \"public_key\": "
36 "\"abcdef12345\"}");
37 BEAST_EXPECT(info[jss::result][jss::error_message] == "Invalid parameters.");
38 }
39 }
40
41 void
43 {
44 testcase("Lookup");
45
46 using namespace jtx;
47 std::string const key = "n949f75evCHwgyP4fPVgaHqNHxUVN15PsJEZ3B3HnXPcPjcZAoy7";
48 Env env{*this, envconfig([&key](std::unique_ptr<Config> cfg) {
49 cfg->section(SECTION_VALIDATORS).append(key);
50 return cfg;
51 })};
52 {
53 auto const info = env.rpc(
54 "json",
55 "manifest",
56 "{ \"public_key\": "
57 "\"" +
58 key + "\"}");
59 BEAST_EXPECT(info[jss::result][jss::requested] == key);
60 BEAST_EXPECT(info[jss::result][jss::status] == "success");
61 }
62 }
63
64 void
65 run() override
66 {
67 testErrors();
68 testLookup();
69 }
70};
71
72BEAST_DEFINE_TESTSUITE(ManifestRPC, rpc, xrpl);
73} // namespace test
74} // namespace xrpl
A testsuite class.
Definition suite.h:51
testcase_t testcase
Memberspace for declaring test cases.
Definition suite.h:147
void run() override
Runs the suite.
A transaction testing environment.
Definition Env.h:119
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:792
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition rpc.h:15
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition envconfig.h:34
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5