20 #include <ripple/basics/StringUtilities.h>
21 #include <ripple/protocol/AmountConversions.h>
22 #include <ripple/protocol/Feature.h>
23 #include <ripple/protocol/Quality.h>
24 #include <ripple/protocol/Rate.h>
25 #include <ripple/protocol/jss.h>
36 testcase(
"No AccountSet");
38 using namespace test::jtx;
40 Account
const alice(
"alice");
41 env.fund(XRP(10000), noripple(alice));
43 auto const jrr = env.le(alice);
44 BEAST_EXPECT((*env.le(alice))[
sfFlags] == 0u);
50 testcase(
"Most Flags");
52 using namespace test::jtx;
53 Account
const alice(
"alice");
57 env.fund(XRP(10000), noripple(alice));
62 env(regkey(alice, alie));
65 auto testFlags = [
this, &alice, &alie, &env](
69 flag < std::numeric_limits<std::uint32_t>::digits;
79 std::find(goodFlags.begin(), goodFlags.end(), flag) !=
83 env.require(nflags(alice, flag));
84 env(fset(alice, flag), sig(alice));
86 env.require(flags(alice, flag));
87 env(fclear(alice, flag), sig(alie));
89 env.require(nflags(alice, flag));
91 BEAST_EXPECT(now_flags == orig_flags);
96 BEAST_EXPECT((*env.le(alice))[
sfFlags] == orig_flags);
97 env(fset(alice, flag), sig(alice));
99 BEAST_EXPECT((*env.le(alice))[
sfFlags] == orig_flags);
100 env(fclear(alice, flag), sig(alie));
102 BEAST_EXPECT((*env.le(alice))[
sfFlags] == orig_flags);
132 testcase(
"Set and reset AccountTxnID");
134 using namespace test::jtx;
136 Account
const alice(
"alice");
137 env.fund(XRP(10000), noripple(alice));
149 BEAST_EXPECT(now_flags == orig_flags);
155 testcase(
"Set NoFreeze");
157 using namespace test::jtx;
159 Account
const alice(
"alice");
160 env.fund(XRP(10000), noripple(alice));
162 env(regkey(alice,
"eric"));
178 using namespace test::jtx;
180 Account
const alice(
"alice");
181 env.fund(XRP(10000), alice);
182 auto jt = noop(alice);
196 BEAST_EXPECT(!env.le(alice)->isFieldPresent(
sfDomain));
202 for (
std::size_t len = maxLength - 1; len <= maxLength + 1; ++len)
207 BEAST_EXPECT(domain2.
length() == len);
211 if (len <= maxLength)
226 testcase(
"MessageKey");
228 using namespace test::jtx;
230 Account
const alice(
"alice");
231 env.fund(XRP(10000), alice);
232 auto jt = noop(alice);
239 strHex(rkp.first.slice()));
243 BEAST_EXPECT(!env.le(alice)->isFieldPresent(
sfMessageKey));
245 using namespace std::string_literals;
253 testcase(
"WalletID");
255 using namespace test::jtx;
257 Account
const alice(
"alice");
258 env.fund(XRP(10000), alice);
259 auto jt = noop(alice);
262 "9633EC8AF54F16B5286DB1D7B519EF49EEFC050C0C8AC4384F1D88ACD1BFDF05";
275 testcase(
"EmailHash");
277 using namespace test::jtx;
279 Account
const alice(
"alice");
280 env.fund(XRP(10000), alice);
281 auto jt = noop(alice);
283 std::string const mh(
"5F31A79367DC3137FADA860C05742EE6");
290 BEAST_EXPECT(!env.le(alice)->isFieldPresent(
sfEmailHash));
303 testcase(
"TransferRate");
305 using namespace test::jtx;
306 auto doTests = [
this](
309 Env env(*
this, features);
311 Account
const alice(
"alice");
312 env.fund(XRP(10000), alice);
314 for (
auto const& r : testData)
316 env(rate(alice, r.set), ter(r.code));
321 BEAST_EXPECT(r.get == 1.0);
325 r.get * QUALITY_ONE);
330 supported_amendments(),
345 using namespace test::jtx;
347 Account
const alice(
"alice");
348 Account
const bob(
"bob");
349 Account
const gw(
"gateway");
350 auto const USD = gw[
"USD"];
357 env.fund(XRP(10000), gw, alice, bob);
359 env.trust(USD(10), alice, bob);
364 auto const amount = USD(1);
366 auto const amountWithRate =
369 env(pay(gw, alice, USD(10)));
371 env(pay(alice, bob, USD(1)), sendmax(USD(10)));
374 env.require(balance(alice, USD(10) - amountWithRate));
375 env.require(balance(bob, USD(1)));
389 env.fund(XRP(10000), gw, alice, bob);
391 env.trust(USD(10), alice, bob);
404 env.app().openLedger().modify(
413 auto replacement = std::make_shared<SLE>(*sle, sle->key());
420 auto const amount = USD(1);
424 env(pay(gw, alice, USD(10)));
425 env(pay(alice, bob, amount), sendmax(USD(10)));
427 env.require(balance(alice, USD(10) - amountWithRate));
428 env.require(balance(bob, amount));
435 testcase(
"Bad inputs");
437 using namespace test::jtx;
439 Account
const alice(
"alice");
440 env.fund(XRP(10000), alice);
478 testcase(
"Require auth");
480 using namespace test::jtx;
482 Account
const alice(
"alice");
483 Account
const bob(
"bob");
485 env.fund(XRP(10000), alice);
492 env(signers(alice, 1, {{bob, 1}}));
509 using namespace test::jtx;
511 Account
const alice(
"alice");
513 env.fund(XRP(10000), alice);
517 env(ticket::create(alice, 1));
519 env.require(owners(alice, 1), tickets(alice, 1));
522 env(noop(alice), ticket::use(ticketSeq + 1), ter(
terPRE_TICKET));
524 env.require(owners(alice, 1), tickets(alice, 1));
529 env(noop(alice), ticket::use(ticketSeq));
531 env.require(owners(alice, 0), tickets(alice, 0));
532 BEAST_EXPECT(aliceSeq == env.seq(alice));
535 env(noop(alice), ticket::use(ticketSeq), ter(
tefNO_TICKET));