rippled
test
rpc
ManifestRPC_test.cpp
1
//------------------------------------------------------------------------------
2
/*
3
This file is part of rippled: https://github.com/ripple/rippled
4
Copyright (c) 2020 Dev Null Productions, LLC
5
6
Permission to use, copy, modify, and/or distribute this software for any
7
purpose with or without fee is hereby granted, provided that the above
8
copyright notice and this permission notice appear in all copies.
9
10
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
*/
18
//==============================================================================
19
20
#include <ripple/beast/unit_test.h>
21
#include <ripple/core/ConfigSections.h>
22
#include <ripple/protocol/jss.h>
23
#include <test/jtx.h>
24
25
#include <
string
>
26
27
namespace
ripple
{
28
namespace
test {
29
30
class
ManifestRPC_test
:
public
beast::unit_test::suite
31
{
32
public
:
33
void
34
testErrors
()
35
{
36
testcase(
"Errors"
);
37
38
using namespace
jtx;
39
Env
env(*
this
);
40
{
41
// manifest with no public key
42
auto
const
info = env.
rpc
(
"json"
,
"manifest"
,
"{ }"
);
43
BEAST_EXPECT(
44
info[jss::result][jss::error_message] ==
45
"Missing field 'public_key'."
);
46
}
47
{
48
// manifest with manlformed public key
49
auto
const
info = env.
rpc
(
50
"json"
,
51
"manifest"
,
52
"{ \"public_key\": "
53
"\"abcdef12345\"}"
);
54
BEAST_EXPECT(
55
info[jss::result][jss::error_message] ==
"Invalid parameters."
);
56
}
57
}
58
59
void
60
testLookup
()
61
{
62
testcase(
"Lookup"
);
63
64
using namespace
jtx;
65
std::string
const
key =
66
"n949f75evCHwgyP4fPVgaHqNHxUVN15PsJEZ3B3HnXPcPjcZAoy7"
;
67
Env
env{*
this
,
envconfig
([&key](
std::unique_ptr<Config>
cfg) {
68
cfg->section(SECTION_VALIDATORS).append(key);
69
return
cfg;
70
})};
71
{
72
auto
const
info = env.rpc(
73
"json"
,
74
"manifest"
,
75
"{ \"public_key\": "
76
"\""
+
77
key +
"\"}"
);
78
BEAST_EXPECT(info[jss::result][jss::requested] == key);
79
BEAST_EXPECT(info[jss::result][jss::status] ==
"success"
);
80
}
81
}
82
83
void
84
run
()
override
85
{
86
testErrors
();
87
testLookup
();
88
}
89
};
90
91
BEAST_DEFINE_TESTSUITE
(ManifestRPC, rpc,
ripple
);
92
}
// namespace test
93
}
// namespace ripple
std::string
STL class.
ripple::test::ManifestRPC_test
Definition:
ManifestRPC_test.cpp:30
ripple::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:711
ripple::test::ManifestRPC_test::testErrors
void testErrors()
Definition:
ManifestRPC_test.cpp:34
ripple::test::ManifestRPC_test::testLookup
void testLookup()
Definition:
ManifestRPC_test.cpp:60
ripple::test::jtx::envconfig
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
Definition:
envconfig.h:54
ripple::test::ManifestRPC_test::run
void run() override
Definition:
ManifestRPC_test.cpp:84
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition:
RCLCensorshipDetector.h:29
std::unique_ptr
STL class.
ripple::test::jtx::Env
A transaction testing environment.
Definition:
Env.h:116
ripple::test::BEAST_DEFINE_TESTSUITE
BEAST_DEFINE_TESTSUITE(DeliverMin, app, ripple)
string
Generated by
1.8.17