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 ripple {
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(
29 info[jss::result][jss::error_message] ==
30 "Missing field 'public_key'.");
31 }
32 {
33 // manifest with manlformed public key
34 auto const info = env.rpc(
35 "json",
36 "manifest",
37 "{ \"public_key\": "
38 "\"abcdef12345\"}");
39 BEAST_EXPECT(
40 info[jss::result][jss::error_message] == "Invalid parameters.");
41 }
42 }
43
44 void
46 {
47 testcase("Lookup");
48
49 using namespace jtx;
50 std::string const key =
51 "n949f75evCHwgyP4fPVgaHqNHxUVN15PsJEZ3B3HnXPcPjcZAoy7";
52 Env env{*this, envconfig([&key](std::unique_ptr<Config> cfg) {
53 cfg->section(SECTION_VALIDATORS).append(key);
54 return cfg;
55 })};
56 {
57 auto const info = env.rpc(
58 "json",
59 "manifest",
60 "{ \"public_key\": "
61 "\"" +
62 key + "\"}");
63 BEAST_EXPECT(info[jss::result][jss::requested] == key);
64 BEAST_EXPECT(info[jss::result][jss::status] == "success");
65 }
66 }
67
68 void
69 run() override
70 {
71 testErrors();
72 testLookup();
73 }
74};
75
76BEAST_DEFINE_TESTSUITE(ManifestRPC, rpc, ripple);
77} // namespace test
78} // namespace ripple
A testsuite class.
Definition suite.h:52
testcase_t testcase
Memberspace for declaring test cases.
Definition suite.h:152
void run() override
Runs the suite.
A transaction testing environment.
Definition Env.h:102
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:772
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition rpc.h:16
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition envconfig.h:35
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6