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;
103 if (
std::find(goodFlags.begin(), goodFlags.end(), flag) !=
107 env.require(nflags(alice, flag));
108 env(fset(alice, flag), sig(alice));
110 env.require(flags(alice, flag));
111 env(fclear(alice, flag), sig(alie));
113 env.require(nflags(alice, flag));
115 BEAST_EXPECT(now_flags == orig_flags);
120 BEAST_EXPECT((*env.le(alice))[
sfFlags] == orig_flags);
121 env(fset(alice, flag), sig(alice));
123 BEAST_EXPECT((*env.le(alice))[
sfFlags] == orig_flags);
124 env(fclear(alice, flag), sig(alie));
126 BEAST_EXPECT((*env.le(alice))[
sfFlags] == orig_flags);
156 testcase(
"Set and reset AccountTxnID");
158 using namespace test::jtx;
160 Account
const alice(
"alice");
161 env.fund(XRP(10000), noripple(alice));
173 BEAST_EXPECT(now_flags == orig_flags);
179 testcase(
"Set NoFreeze");
181 using namespace test::jtx;
183 Account
const alice(
"alice");
184 env.fund(XRP(10000), noripple(alice));
186 env(regkey(alice,
"eric"));
202 using namespace test::jtx;
204 Account
const alice(
"alice");
205 env.fund(XRP(10000), alice);
206 auto jt = noop(alice);
220 BEAST_EXPECT(!env.le(alice)->isFieldPresent(
sfDomain));
226 for (
std::size_t len = maxLength - 1; len <= maxLength + 1; ++len)
231 BEAST_EXPECT(domain2.
length() == len);
235 if (len <= maxLength)
250 testcase(
"MessageKey");
252 using namespace test::jtx;
254 Account
const alice(
"alice");
255 env.fund(XRP(10000), alice);
256 auto jt = noop(alice);
263 strHex(rkp.first.slice()));
267 BEAST_EXPECT(!env.le(alice)->isFieldPresent(
sfMessageKey));
269 using namespace std::string_literals;
277 testcase(
"WalletID");
279 using namespace test::jtx;
281 Account
const alice(
"alice");
282 env.fund(XRP(10000), alice);
283 auto jt = noop(alice);
286 "9633EC8AF54F16B5286DB1D7B519EF49EEFC050C0C8AC4384F1D88ACD1BFDF05";
299 testcase(
"EmailHash");
301 using namespace test::jtx;
303 Account
const alice(
"alice");
304 env.fund(XRP(10000), alice);
305 auto jt = noop(alice);
307 std::string const mh(
"5F31A79367DC3137FADA860C05742EE6");
314 BEAST_EXPECT(!env.le(alice)->isFieldPresent(
sfEmailHash));
327 testcase(
"TransferRate");
329 using namespace test::jtx;
330 auto doTests = [
this](
333 Env env(*
this, features);
335 Account
const alice(
"alice");
336 env.fund(XRP(10000), alice);
338 for (
auto const& r : testData)
340 env(rate(alice, r.set), ter(r.code));
345 BEAST_EXPECT(r.get == 1.0);
349 r.get * QUALITY_ONE);
354 supported_amendments(),
369 using namespace test::jtx;
371 Account
const alice(
"alice");
372 Account
const bob(
"bob");
373 Account
const gw(
"gateway");
374 auto const USD = gw[
"USD"];
381 env.fund(XRP(10000), gw, alice, bob);
383 env.trust(USD(10), alice, bob);
388 auto const amount = USD(1);
390 auto const amountWithRate =
393 env(pay(gw, alice, USD(10)));
395 env(pay(alice, bob, USD(1)), sendmax(USD(10)));
398 env.require(balance(alice, USD(10) - amountWithRate));
399 env.require(balance(bob, USD(1)));
413 env.fund(XRP(10000), gw, alice, bob);
415 env.trust(USD(10), alice, bob);
429 uint256 const nftId0{token::getNextID(env, gw, 0u)};
430 env(token::mint(gw, 0u));
433 env(token::burn(gw, nftId0));
440 env.app().openLedger().modify(
449 auto replacement = std::make_shared<SLE>(*sle, sle->key());
456 auto const amount = USD(1);
460 env(pay(gw, alice, USD(10)));
461 env(pay(alice, bob, amount), sendmax(USD(10)));
463 env.require(balance(alice, USD(10) - amountWithRate));
464 env.require(balance(bob, amount));
471 testcase(
"Bad inputs");
473 using namespace test::jtx;
475 Account
const alice(
"alice");
476 env.fund(XRP(10000), alice);
514 testcase(
"Require auth");
516 using namespace test::jtx;
518 Account
const alice(
"alice");
519 Account
const bob(
"bob");
521 env.fund(XRP(10000), alice);
528 env(signers(alice, 1, {{bob, 1}}));
545 using namespace test::jtx;
547 Account
const alice(
"alice");
549 env.fund(XRP(10000), alice);
553 env(ticket::create(alice, 1));
555 env.require(owners(alice, 1), tickets(alice, 1));
558 env(noop(alice), ticket::use(ticketSeq + 1), ter(
terPRE_TICKET));
560 env.require(owners(alice, 1), tickets(alice, 1));
565 env(noop(alice), ticket::use(ticketSeq));
567 env.require(owners(alice, 0), tickets(alice, 0));
568 BEAST_EXPECT(aliceSeq == env.seq(alice));
571 env(noop(alice), ticket::use(ticketSeq), ter(
tefNO_TICKET));