20 #include <ripple/basics/contract.h>
21 #include <ripple/beast/unit_test.h>
22 #include <ripple/rpc/Status.h>
31 template <
typename Type>
44 expect(s.empty(),
"String for OK status");
49 expect(s.empty(),
"String for OK status");
54 expect(s.empty(),
"String for 0 status");
59 expect(s.empty(),
"String for tesSUCCESS");
64 expect(s.empty(),
"String for rpcSUCCESS");
79 expect(s ==
"temBAD_AMOUNT: Can only send positive amounts.", s);
84 expect(s ==
"badSyntax: Syntax error.", s);
104 template <
typename Type>
117 expect(!
value_,
"Value for empty status");
120 expect(!
value_,
"Value for 0 status");
123 expect(!
value_,
"Value for OK status");
126 expect(!
value_,
"Value for tesSUCCESS");
129 expect(!
value_,
"Value for rpcSUCCESS");
132 template <
typename Type>
143 auto prefix = label +
": ";
144 expect(
bool(
value_), prefix +
"No value");
146 auto error =
value_[jss::error];
147 expect(
bool(error), prefix +
"No error.");
149 auto code = error[jss::code].asInt();
155 auto m = error[jss::message].asString();
156 expect(m == message, m +
" != " + message);
158 auto d = error[jss::data];
159 size_t s1 = d.size(), s2 = messages.
size();
164 for (
auto i = 0; i <
std::min(s1, s2); ++i)
166 auto ds = d[i].asString();
167 expect(ds == messages[i], prefix + ds +
" != " + messages[i]);
179 "temBAD_AMOUNT: Can only send positive amounts.");
184 {
"An error.",
"Another error."},
185 "badSyntax: Syntax error.");
187 expectFill(
"integer message", 23, {
"Stuff."},
"23");
202 expect(msgs.size() == 1,
"Wrong number of messages");
203 expect(msgs[0] ==
"path=sdcdfd", msgs[0]);
207 expect(
false,
"Didn't catch a Status");
BEAST_DEFINE_TESTSUITE(AccountLinesRPC, app, ripple)
std::string codeString() const
Strings const & messages() const
std::string codeString(Type t)
void expectFill(std::string const &label, Type status, Status::Strings messages, std::string const &message)
Status represents the results of an operation that might fail.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
TER toTER() const
Returns the Status as a TER.
void clear()
Remove all object members and array elements.
void fillJson(Json::Value &)
Fill a Json::Value with an RPC 2.0 response.