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;
97 if (
std::find(goodFlags.begin(), goodFlags.end(), flag) !=
101 env.require(nflags(alice, flag));
102 env(fset(alice, flag), sig(alice));
104 env.require(flags(alice, flag));
105 env(fclear(alice, flag), sig(alie));
107 env.require(nflags(alice, flag));
109 BEAST_EXPECT(now_flags == orig_flags);
114 BEAST_EXPECT((*env.le(alice))[
sfFlags] == orig_flags);
115 env(fset(alice, flag), sig(alice));
117 BEAST_EXPECT((*env.le(alice))[
sfFlags] == orig_flags);
118 env(fclear(alice, flag), sig(alie));
120 BEAST_EXPECT((*env.le(alice))[
sfFlags] == orig_flags);
150 testcase(
"Set and reset AccountTxnID");
152 using namespace test::jtx;
154 Account
const alice(
"alice");
155 env.fund(XRP(10000), noripple(alice));
167 BEAST_EXPECT(now_flags == orig_flags);
173 testcase(
"Set NoFreeze");
175 using namespace test::jtx;
177 Account
const alice(
"alice");
178 env.fund(XRP(10000), noripple(alice));
180 env(regkey(alice,
"eric"));
196 using namespace test::jtx;
198 Account
const alice(
"alice");
199 env.fund(XRP(10000), alice);
200 auto jt = noop(alice);
214 BEAST_EXPECT(!env.le(alice)->isFieldPresent(
sfDomain));
220 for (
std::size_t len = maxLength - 1; len <= maxLength + 1; ++len)
225 BEAST_EXPECT(domain2.
length() == len);
229 if (len <= maxLength)
244 testcase(
"MessageKey");
246 using namespace test::jtx;
248 Account
const alice(
"alice");
249 env.fund(XRP(10000), alice);
250 auto jt = noop(alice);
257 strHex(rkp.first.slice()));
261 BEAST_EXPECT(!env.le(alice)->isFieldPresent(
sfMessageKey));
263 using namespace std::string_literals;
271 testcase(
"WalletID");
273 using namespace test::jtx;
275 Account
const alice(
"alice");
276 env.fund(XRP(10000), alice);
277 auto jt = noop(alice);
280 "9633EC8AF54F16B5286DB1D7B519EF49EEFC050C0C8AC4384F1D88ACD1BFDF05";
293 testcase(
"EmailHash");
295 using namespace test::jtx;
297 Account
const alice(
"alice");
298 env.fund(XRP(10000), alice);
299 auto jt = noop(alice);
301 std::string const mh(
"5F31A79367DC3137FADA860C05742EE6");
308 BEAST_EXPECT(!env.le(alice)->isFieldPresent(
sfEmailHash));
321 testcase(
"TransferRate");
323 using namespace test::jtx;
324 auto doTests = [
this](
327 Env env(*
this, features);
329 Account
const alice(
"alice");
330 env.fund(XRP(10000), alice);
332 for (
auto const& r : testData)
334 env(rate(alice, r.set), ter(r.code));
339 BEAST_EXPECT(r.get == 1.0);
343 r.get * QUALITY_ONE);
348 supported_amendments(),
363 using namespace test::jtx;
365 Account
const alice(
"alice");
366 Account
const bob(
"bob");
367 Account
const gw(
"gateway");
368 auto const USD = gw[
"USD"];
375 env.fund(XRP(10000), gw, alice, bob);
377 env.trust(USD(10), alice, bob);
382 auto const amount = USD(1);
384 auto const amountWithRate =
387 env(pay(gw, alice, USD(10)));
389 env(pay(alice, bob, USD(1)), sendmax(USD(10)));
392 env.require(balance(alice, USD(10) - amountWithRate));
393 env.require(balance(bob, USD(1)));
407 env.fund(XRP(10000), gw, alice, bob);
409 env.trust(USD(10), alice, bob);
423 uint256 const nftId0{token::getNextID(env, gw, 0u)};
424 env(token::mint(gw, 0u));
427 env(token::burn(gw, nftId0));
434 env.app().openLedger().modify(
443 auto replacement = std::make_shared<SLE>(*sle, sle->key());
450 auto const amount = USD(1);
454 env(pay(gw, alice, USD(10)));
455 env(pay(alice, bob, amount), sendmax(USD(10)));
457 env.require(balance(alice, USD(10) - amountWithRate));
458 env.require(balance(bob, amount));
465 testcase(
"Bad inputs");
467 using namespace test::jtx;
469 Account
const alice(
"alice");
470 env.fund(XRP(10000), alice);
508 testcase(
"Require auth");
510 using namespace test::jtx;
512 Account
const alice(
"alice");
513 Account
const bob(
"bob");
515 env.fund(XRP(10000), alice);
522 env(signers(alice, 1, {{bob, 1}}));
539 using namespace test::jtx;
541 Account
const alice(
"alice");
543 env.fund(XRP(10000), alice);
547 env(ticket::create(alice, 1));
549 env.require(owners(alice, 1), tickets(alice, 1));
552 env(noop(alice), ticket::use(ticketSeq + 1), ter(
terPRE_TICKET));
554 env.require(owners(alice, 1), tickets(alice, 1));
559 env(noop(alice), ticket::use(ticketSeq));
561 env.require(owners(alice, 0), tickets(alice, 0));
562 BEAST_EXPECT(aliceSeq == env.seq(alice));
565 env(noop(alice), ticket::use(ticketSeq), ter(
tefNO_TICKET));