xrpld
Loading...
Searching...
No Matches
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
15namespace xrpl::test {
16
18{
19public:
20 void
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
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
74BEAST_DEFINE_TESTSUITE(ManifestRPC, rpc, xrpl);
75} // namespace xrpl::test
A testsuite class.
Definition suite.h:50
TestcaseT testcase
Memberspace for declaring test cases.
Definition suite.h:149
void run() override
Runs the suite.
A transaction testing environment.
Definition Env.h:143
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:864
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition envconfig.h:28
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
static constexpr auto kValidators
Definition Constants.h:73