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;
86 std::find(goodFlags.begin(), goodFlags.end(), flag) !=
90 env.require(nflags(alice, flag));
91 env(fset(alice, flag), sig(alice));
93 env.require(flags(alice, flag));
94 env(fclear(alice, flag), sig(alie));
96 env.require(nflags(alice, flag));
98 BEAST_EXPECT(now_flags == orig_flags);
103 BEAST_EXPECT((*env.le(alice))[
sfFlags] == orig_flags);
104 env(fset(alice, flag), sig(alice));
106 BEAST_EXPECT((*env.le(alice))[
sfFlags] == orig_flags);
107 env(fclear(alice, flag), sig(alie));
109 BEAST_EXPECT((*env.le(alice))[
sfFlags] == orig_flags);
139 testcase(
"Set and reset AccountTxnID");
141 using namespace test::jtx;
143 Account
const alice(
"alice");
144 env.fund(XRP(10000), noripple(alice));
156 BEAST_EXPECT(now_flags == orig_flags);
162 testcase(
"Set NoFreeze");
164 using namespace test::jtx;
166 Account
const alice(
"alice");
167 env.fund(XRP(10000), noripple(alice));
169 env(regkey(alice,
"eric"));
185 using namespace test::jtx;
187 Account
const alice(
"alice");
188 env.fund(XRP(10000), alice);
189 auto jt = noop(alice);
203 BEAST_EXPECT(!env.le(alice)->isFieldPresent(
sfDomain));
209 for (
std::size_t len = maxLength - 1; len <= maxLength + 1; ++len)
214 BEAST_EXPECT(domain2.
length() == len);
218 if (len <= maxLength)
233 testcase(
"MessageKey");
235 using namespace test::jtx;
237 Account
const alice(
"alice");
238 env.fund(XRP(10000), alice);
239 auto jt = noop(alice);
246 strHex(rkp.first.slice()));
250 BEAST_EXPECT(!env.le(alice)->isFieldPresent(
sfMessageKey));
252 using namespace std::string_literals;
260 testcase(
"WalletID");
262 using namespace test::jtx;
264 Account
const alice(
"alice");
265 env.fund(XRP(10000), alice);
266 auto jt = noop(alice);
269 "9633EC8AF54F16B5286DB1D7B519EF49EEFC050C0C8AC4384F1D88ACD1BFDF05";
282 testcase(
"EmailHash");
284 using namespace test::jtx;
286 Account
const alice(
"alice");
287 env.fund(XRP(10000), alice);
288 auto jt = noop(alice);
290 std::string const mh(
"5F31A79367DC3137FADA860C05742EE6");
297 BEAST_EXPECT(!env.le(alice)->isFieldPresent(
sfEmailHash));
310 testcase(
"TransferRate");
312 using namespace test::jtx;
313 auto doTests = [
this](
316 Env env(*
this, features);
318 Account
const alice(
"alice");
319 env.fund(XRP(10000), alice);
321 for (
auto const& r : testData)
323 env(rate(alice, r.set), ter(r.code));
328 BEAST_EXPECT(r.get == 1.0);
332 r.get * QUALITY_ONE);
337 supported_amendments(),
352 using namespace test::jtx;
354 Account
const alice(
"alice");
355 Account
const bob(
"bob");
356 Account
const gw(
"gateway");
357 auto const USD = gw[
"USD"];
364 env.fund(XRP(10000), gw, alice, bob);
366 env.trust(USD(10), alice, bob);
371 auto const amount = USD(1);
373 auto const amountWithRate =
376 env(pay(gw, alice, USD(10)));
378 env(pay(alice, bob, USD(1)), sendmax(USD(10)));
381 env.require(balance(alice, USD(10) - amountWithRate));
382 env.require(balance(bob, USD(1)));
396 env.fund(XRP(10000), gw, alice, bob);
398 env.trust(USD(10), alice, bob);
412 uint256 const nftId0{token::getNextID(env, gw, 0u)};
413 env(token::mint(gw, 0u));
416 env(token::burn(gw, nftId0));
423 env.app().openLedger().modify(
432 auto replacement = std::make_shared<SLE>(*sle, sle->key());
439 auto const amount = USD(1);
443 env(pay(gw, alice, USD(10)));
444 env(pay(alice, bob, amount), sendmax(USD(10)));
446 env.require(balance(alice, USD(10) - amountWithRate));
447 env.require(balance(bob, amount));
454 testcase(
"Bad inputs");
456 using namespace test::jtx;
458 Account
const alice(
"alice");
459 env.fund(XRP(10000), alice);
497 testcase(
"Require auth");
499 using namespace test::jtx;
501 Account
const alice(
"alice");
502 Account
const bob(
"bob");
504 env.fund(XRP(10000), alice);
511 env(signers(alice, 1, {{bob, 1}}));
528 using namespace test::jtx;
530 Account
const alice(
"alice");
532 env.fund(XRP(10000), alice);
536 env(ticket::create(alice, 1));
538 env.require(owners(alice, 1), tickets(alice, 1));
541 env(noop(alice), ticket::use(ticketSeq + 1), ter(
terPRE_TICKET));
543 env.require(owners(alice, 1), tickets(alice, 1));
548 env(noop(alice), ticket::use(ticketSeq));
550 env.require(owners(alice, 0), tickets(alice, 0));
551 BEAST_EXPECT(aliceSeq == env.seq(alice));
554 env(noop(alice), ticket::use(ticketSeq), ter(
tefNO_TICKET));