2#include <test/jtx/Account.h>
3#include <test/jtx/Env.h>
4#include <test/jtx/amount.h>
5#include <test/jtx/balance.h>
6#include <test/jtx/escrow.h>
7#include <test/jtx/fee.h>
8#include <test/jtx/flags.h>
9#include <test/jtx/mpt.h>
10#include <test/jtx/pay.h>
11#include <test/jtx/rate.h>
12#include <test/jtx/ter.h>
13#include <test/jtx/trust.h>
14#include <test/jtx/txflags.h>
16#include <xrpl/beast/unit_test/suite.h>
17#include <xrpl/beast/utility/Journal.h>
18#include <xrpl/core/ServiceRegistry.h>
19#include <xrpl/json/json_value.h>
20#include <xrpl/json/to_string.h>
21#include <xrpl/ledger/ApplyView.h>
22#include <xrpl/ledger/Dir.h>
23#include <xrpl/ledger/OpenView.h>
24#include <xrpl/ledger/Sandbox.h>
25#include <xrpl/protocol/AccountID.h>
26#include <xrpl/protocol/Feature.h>
27#include <xrpl/protocol/Indexes.h>
28#include <xrpl/protocol/Issue.h>
29#include <xrpl/protocol/MPTIssue.h>
30#include <xrpl/protocol/Protocol.h>
31#include <xrpl/protocol/SField.h>
32#include <xrpl/protocol/STAmount.h>
33#include <xrpl/protocol/TER.h>
34#include <xrpl/protocol/TxFlags.h>
35#include <xrpl/protocol/UintTypes.h>
36#include <xrpl/protocol/jss.h>
52 if (sle && sle->isFieldPresent(sfLockedAmount))
53 return (*sle)[sfLockedAmount];
61 if (sle && sle->isFieldPresent(sfLockedAmount))
62 return (*sle)[sfLockedAmount];
70 params[jss::account] = account.human();
71 auto jrr = env.
rpc(
"json",
"gateway_balances",
to_string(params));
72 auto const result = jrr[jss::result];
74 if (obligations.isNull())
75 return {
STAmount(issue, 0), account.name()};
77 return {amount, account.name()};
84 params[jss::account] = account.human();
85 auto jrr = env.
rpc(
"json",
"gateway_balances",
to_string(params));
86 auto const result = jrr[jss::result];
89 return {
STAmount(issue, 0), account.name()};
91 return {amount, account.name()};
102 for (
bool const withTokenEscrow : {
false,
true})
104 auto const amend = withTokenEscrow ? features : features - featureTokenEscrow;
105 Env env{*
this, amend};
106 auto const baseFee = env.
current()->fees().base;
107 auto const alice =
Account(
"alice");
108 auto const bob =
Account(
"bob");
109 auto const gw =
Account{
"gateway"};
110 auto const usd = gw[
"USD"];
111 env.
fund(
XRP(5000), alice, bob, gw);
112 env(
fset(gw, asfAllowTrustLineLocking));
114 env.
trust(usd(10'000), alice, bob);
116 env(
pay(gw, alice, usd(5000)));
117 env(
pay(gw, bob, usd(5000)));
123 auto const seq1 = env.
seq(alice);
137 auto const seq2 = env.
seq(alice);
149 for (
bool const withTokenEscrow : {
false,
true})
151 auto const amend = withTokenEscrow ? features : features - featureTokenEscrow;
152 Env env{*
this, amend};
153 auto const baseFee = env.
current()->fees().base;
154 auto const alice =
Account(
"alice");
155 auto const bob =
Account(
"bob");
156 auto const gw =
Account{
"gateway"};
157 auto const usd = gw[
"USD"];
158 env.
fund(
XRP(5000), alice, bob, gw);
159 env(
fset(gw, asfAllowTrustLineLocking));
161 env.
trust(usd(10'000), alice, bob);
163 env(
pay(gw, alice, usd(5000)));
164 env(
pay(gw, bob, usd(5000)));
167 auto const seq1 = env.
seq(alice);
188 Env env{*
this, features};
189 auto const baseFee = env.
current()->fees().base;
190 auto const alice =
Account(
"alice");
191 auto const bob =
Account(
"bob");
192 auto const gw =
Account{
"gateway"};
193 auto const usd = gw[
"USD"];
194 env.
fund(
XRP(5000), alice, bob, gw);
195 env(
fset(gw, asfAllowTrustLineLocking));
197 env.
trust(usd(10'000), alice, bob);
199 env(
pay(gw, alice, usd(5000)));
200 env(
pay(gw, bob, usd(5000)));
204 auto const seq1 = env.
seq(alice);
212 auto const seq2 = env.
seq(alice);
221 env(
fclear(gw, asfAllowTrustLineLocking));
255 Env env{*
this, features};
256 auto const alice =
Account(
"alice");
257 auto const bob =
Account(
"bob");
258 auto const gw =
Account{
"gateway"};
259 auto const usd = gw[
"USD"];
260 env.
fund(
XRP(5000), alice, bob, gw);
271 Env env{*
this, features};
272 auto const baseFee = env.
current()->fees().base;
273 auto const alice =
Account(
"alice");
274 auto const bob =
Account(
"bob");
275 auto const gw =
Account{
"gateway"};
276 auto const usd = gw[
"USD"];
277 env.
fund(
XRP(5000), alice, bob, gw);
289 Env env{*
this, features};
290 auto const baseFee = env.
current()->fees().base;
291 auto const alice =
Account(
"alice");
292 auto const bob =
Account(
"bob");
293 auto const gw =
Account{
"gateway"};
295 env.
fund(
XRP(5000), alice, bob, gw);
315 Env env{*
this, features};
316 auto const baseFee = env.
current()->fees().base;
317 auto const alice =
Account(
"alice");
318 auto const bob =
Account(
"bob");
319 auto const gw =
Account{
"gateway"};
320 auto const usd = gw[
"USD"];
321 env.
fund(
XRP(5000), alice, bob, gw);
333 Env env{*
this, features};
334 auto const baseFee = env.
current()->fees().base;
335 auto const alice =
Account(
"alice");
336 auto const bob =
Account(
"bob");
337 auto const gw =
Account{
"gateway"};
338 auto const usd = gw[
"USD"];
339 env.
fund(
XRP(5000), alice, bob);
353 Env env{*
this, features};
354 auto const baseFee = env.
current()->fees().base;
355 auto const alice =
Account(
"alice");
356 auto const bob =
Account(
"bob");
357 auto const gw =
Account{
"gateway"};
358 auto const usd = gw[
"USD"];
359 env.
fund(
XRP(5000), alice, bob, gw);
361 env.
trust(usd(10'000), alice, bob);
363 env(
pay(gw, alice, usd(5000)));
364 env(
pay(gw, bob, usd(5000)));
377 Env env{*
this, features};
378 auto const baseFee = env.
current()->fees().base;
379 auto const alice =
Account(
"alice");
380 auto const bob =
Account(
"bob");
381 auto const gw =
Account{
"gateway"};
382 auto const usd = gw[
"USD"];
383 env.
fund(
XRP(5000), alice, bob, gw);
384 env(
fset(gw, asfAllowTrustLineLocking));
398 Env env{*
this, features};
399 auto const baseFee = env.
current()->fees().base;
400 auto const alice =
Account(
"alice");
401 auto const bob =
Account(
"bob");
402 auto const gw =
Account{
"gateway"};
403 auto const usd = gw[
"USD"];
404 env.
fund(
XRP(5000), alice, bob, gw);
405 env(
fset(gw, asfAllowTrustLineLocking));
406 env(
fset(gw, asfRequireAuth));
408 env.
trust(usd(10'000), alice, bob);
421 Env env{*
this, features};
422 auto const baseFee = env.
current()->fees().base;
423 auto const alice =
Account(
"alice");
424 auto const bob =
Account(
"bob");
425 auto const gw =
Account{
"gateway"};
426 auto const usd = gw[
"USD"];
427 auto const aliceUSD = alice[
"USD"];
428 env.
fund(
XRP(5000), alice, bob, gw);
429 env(
fset(gw, asfAllowTrustLineLocking));
430 env(
fset(gw, asfRequireAuth));
433 env.
trust(usd(10'000), alice, bob);
447 Env env{*
this, features};
448 auto const alice =
Account(
"alice");
449 auto const bob =
Account(
"bob");
450 auto const gw =
Account{
"gateway"};
451 auto const usd = gw[
"USD"];
452 auto const baseFee = env.
current()->fees().base;
453 env.
fund(
XRP(10'000), alice, bob, gw);
454 env(
fset(gw, asfAllowTrustLineLocking));
456 env(
trust(alice, usd(100'000)));
457 env(
trust(bob, usd(100'000)));
459 env(
pay(gw, alice, usd(10'000)));
460 env(
pay(gw, bob, usd(10'000)));
464 env(
trust(gw, usd(10'000), alice, tfSetFreeze));
478 Env env{*
this, features};
479 auto const alice =
Account(
"alice");
480 auto const bob =
Account(
"bob");
481 auto const gw =
Account{
"gateway"};
482 auto const usd = gw[
"USD"];
483 auto const baseFee = env.
current()->fees().base;
484 env.
fund(
XRP(10'000), alice, bob, gw);
485 env(
fset(gw, asfAllowTrustLineLocking));
487 env(
trust(alice, usd(100'000)));
488 env(
trust(bob, usd(100'000)));
490 env(
pay(gw, alice, usd(10'000)));
491 env(
pay(gw, bob, usd(10'000)));
495 env(
trust(gw, usd(10'000), bob, tfSetFreeze));
509 Env env{*
this, features};
510 auto const alice =
Account(
"alice");
511 auto const bob =
Account(
"bob");
512 auto const gw =
Account{
"gateway"};
513 auto const usd = gw[
"USD"];
514 auto const baseFee = env.
current()->fees().base;
515 env.
fund(
XRP(10'000), alice, bob, gw);
516 env(
fset(gw, asfAllowTrustLineLocking));
518 env(
trust(alice, usd(100'000)));
519 env(
trust(bob, usd(100'000)));
533 Env env{*
this, features};
534 auto const alice =
Account(
"alice");
535 auto const bob =
Account(
"bob");
536 auto const gw =
Account{
"gateway"};
537 auto const usd = gw[
"USD"];
538 auto const baseFee = env.
current()->fees().base;
539 env.
fund(
XRP(10'000), alice, bob, gw);
540 env(
fset(gw, asfAllowTrustLineLocking));
542 env(
trust(alice, usd(100'000)));
543 env(
trust(bob, usd(100'000)));
545 env(
pay(gw, alice, usd(10'000)));
546 env(
pay(gw, bob, usd(10'000)));
559 Env env{*
this, features};
560 auto const alice =
Account(
"alice");
561 auto const bob =
Account(
"bob");
562 auto const gw =
Account{
"gateway"};
563 auto const usd = gw[
"USD"];
564 auto const baseFee = env.
current()->fees().base;
565 env.
fund(
XRP(10'000), alice, bob, gw);
566 env(
fset(gw, asfAllowTrustLineLocking));
568 env.
trust(usd(100000000000000000), alice);
569 env.
trust(usd(100000000000000000), bob);
571 env(
pay(gw, alice, usd(10000000000000000)));
572 env(
pay(gw, bob, usd(1)));
575 bool const largeMantissa =
576 features[featureSingleAssetVault] || features[featureLendingProtocol];
597 Env env{*
this, features};
598 auto const baseFee = env.
current()->fees().base;
599 auto const alice =
Account(
"alice");
600 auto const bob =
Account(
"bob");
601 auto const gw =
Account{
"gateway"};
602 auto const usd = gw[
"USD"];
603 auto const aliceUSD = alice[
"USD"];
604 auto const bobUSD = bob[
"USD"];
605 env.
fund(
XRP(5000), alice, bob, gw);
606 env(
fset(gw, asfAllowTrustLineLocking));
607 env(
fset(gw, asfRequireAuth));
611 env.
trust(usd(10'000), alice, bob);
613 env(
pay(gw, alice, usd(10'000)));
614 env(
pay(gw, bob, usd(10'000)));
617 auto const seq1 = env.
seq(alice);
625 env(
pay(bob, gw, usd(10'000)));
627 env(
trust(bob, usd(0)));
630 env.
trust(usd(10'000), bob);
644 Env env{*
this, features};
645 auto const baseFee = env.
current()->fees().base;
646 auto const alice =
Account(
"alice");
647 auto const bob =
Account(
"bob");
648 auto const gw =
Account{
"gateway"};
649 auto const usd = gw[
"USD"];
650 env.
fund(
XRP(5000), alice, bob, gw);
651 env(
fset(gw, asfAllowTrustLineLocking));
653 env.
trust(usd(10'000), alice, bob);
655 env(
pay(gw, alice, usd(10'000)));
656 env(
pay(gw, bob, usd(10'000)));
659 auto const seq1 = env.
seq(alice);
668 env(
trust(gw, usd(10'000), bob, tfSetFreeze | tfSetDeepFreeze));
689 Env env{*
this, features};
690 auto const baseFee = env.
current()->fees().base;
691 auto const acctReserve = env.
current()->fees().reserve;
692 auto const incReserve = env.
current()->fees().increment;
693 auto const alice =
Account(
"alice");
694 auto const bob =
Account(
"bob");
695 auto const gw =
Account{
"gateway"};
696 auto const usd = gw[
"USD"];
697 env.
fund(
XRP(5000), alice, gw);
698 env.
fund(acctReserve + (incReserve - 1), bob);
700 env(
fset(gw, asfAllowTrustLineLocking));
702 env.
trust(usd(10'000), alice);
704 env(
pay(gw, alice, usd(10'000)));
707 auto const seq1 = env.
seq(alice);
726 Env env{*
this, features};
727 auto const baseFee = env.
current()->fees().base;
728 auto const alice =
Account(
"alice");
729 auto const bob =
Account(
"bob");
730 auto const gw =
Account{
"gateway"};
731 auto const usd = gw[
"USD"];
732 env.
fund(
XRP(5000), alice, bob, gw);
734 env(
fset(gw, asfAllowTrustLineLocking));
736 env.
trust(usd(10'000), alice);
738 env(
pay(gw, alice, usd(10'000)));
741 auto const seq1 = env.
seq(alice);
760 Env env{*
this, features};
761 auto const baseFee = env.
current()->fees().base;
762 auto const alice =
Account(
"alice");
763 auto const bob =
Account(
"bob");
764 auto const gw =
Account{
"gateway"};
765 auto const usd = gw[
"USD"];
766 env.
fund(
XRP(5000), alice, bob, gw);
768 env(
fset(gw, asfAllowTrustLineLocking));
770 env.
trust(usd(1000), alice, bob);
772 env(
pay(gw, alice, usd(1000)));
775 auto const seq1 = env.
seq(alice);
783 env.
trust(usd(1), bob);
797 Env env{*
this, features};
798 auto const baseFee = env.
current()->fees().base;
799 auto const alice =
Account(
"alice");
800 auto const bob =
Account(
"bob");
801 auto const gw =
Account{
"gateway"};
802 auto const usd = gw[
"USD"];
803 env.
fund(
XRP(5000), alice, bob, gw);
805 env(
fset(gw, asfAllowTrustLineLocking));
807 env.
trust(usd(1000), alice, bob);
809 env(
pay(gw, alice, usd(1000)));
812 auto const seq1 = env.
seq(alice);
820 env.
trust(usd(1), bob);
824 auto const bobPreLimit = env.
limit(bob, usd);
834 BEAST_EXPECT(env.
limit(bob, usd) == bobPreLimit);
847 Env env{*
this, features};
848 auto const baseFee = env.
current()->fees().base;
849 auto const alice =
Account(
"alice");
850 auto const bob =
Account(
"bob");
851 auto const gw =
Account{
"gateway"};
852 auto const usd = gw[
"USD"];
853 auto const aliceUSD = alice[
"USD"];
854 auto const bobUSD = bob[
"USD"];
855 env.
fund(
XRP(5000), alice, bob, gw);
856 env(
fset(gw, asfAllowTrustLineLocking));
857 env(
fset(gw, asfRequireAuth));
861 env.
trust(usd(10'000), alice, bob);
863 env(
pay(gw, alice, usd(10'000)));
864 env(
pay(gw, bob, usd(10'000)));
867 auto const seq1 = env.
seq(alice);
875 env(
pay(alice, gw, usd(9'999)));
877 env(
trust(alice, usd(0)));
880 env.
trust(usd(10'000), alice);
897 Env env{*
this, features};
898 auto const baseFee = env.
current()->fees().base;
899 auto const alice =
Account(
"alice");
900 auto const bob =
Account(
"bob");
902 auto const usd = gw[
"USD"];
904 env.
fund(
XRP(10'000), alice, bob, gw);
907 env(
fset(gw, asfAllowTrustLineLocking));
910 env.
trust(usd(100'000), alice);
911 env.
trust(usd(100'000), bob);
914 env(
pay(gw, alice, usd(10'000)));
917 auto const seq = env.
seq(alice);
924 BEAST_EXPECT(env.
balance(alice, usd) == usd(9'000));
926 env(
pay(alice, gw, usd(9'000)));
929 env(
trust(alice, usd(0)));
933 BEAST_EXPECT(!env.
current()->exists(trustLineKey));
938 auto const expectedResult = env.
current()->rules().enabled(fixCleanup3_2_0)
944 if (env.
current()->rules().enabled(fixCleanup3_2_0))
947 BEAST_EXPECT(env.
current()->exists(trustLineKey));
948 BEAST_EXPECT(env.
balance(alice, usd) == usd(1'000));
961 Env env{*
this, features};
962 auto const baseFee = env.
current()->fees().base;
963 auto const alice =
Account(
"alice");
964 auto const bob =
Account(
"bob");
965 auto const gw =
Account{
"gateway"};
966 auto const usd = gw[
"USD"];
967 env.
fund(
XRP(5000), alice, bob, gw);
968 env(
fset(gw, asfAllowTrustLineLocking));
970 env.
trust(usd(10'000), alice, bob);
972 env(
pay(gw, alice, usd(5'000)));
973 env(
pay(gw, bob, usd(5'000)));
976 auto const outstandingUSD = usd(10'000);
979 auto const seq1 = env.
seq(alice);
981 auto const preAliceUSD = env.
balance(alice, usd);
982 auto const preBobUSD = env.
balance(bob, usd);
990 BEAST_EXPECT(env.
balance(alice, usd) == preAliceUSD - usd(1'000));
991 BEAST_EXPECT(env.
balance(bob, usd) == preBobUSD);
992 BEAST_EXPECT(
issuerBalance(env, gw, usd) == outstandingUSD - usd(1'000));
996 auto const preAliceUSD = env.
balance(alice, usd);
997 auto const preBobUSD = env.
balance(bob, usd);
1005 BEAST_EXPECT(env.
balance(alice, usd) == preAliceUSD);
1006 BEAST_EXPECT(env.
balance(bob, usd) == preBobUSD + usd(1'000));
1007 BEAST_EXPECT(
issuerBalance(env, gw, usd) == outstandingUSD);
1012 auto const seq2 = env.
seq(alice);
1014 auto const preAliceUSD = env.
balance(alice, usd);
1015 auto const preBobUSD = env.
balance(bob, usd);
1024 BEAST_EXPECT(env.
balance(alice, usd) == preAliceUSD - usd(1'000));
1025 BEAST_EXPECT(env.
balance(bob, usd) == preBobUSD);
1026 BEAST_EXPECT(
issuerBalance(env, gw, usd) == outstandingUSD - usd(1'000));
1030 auto const preAliceUSD = env.
balance(alice, usd);
1031 auto const preBobUSD = env.
balance(bob, usd);
1035 BEAST_EXPECT(env.
balance(alice, usd) == preAliceUSD + usd(1'000));
1036 BEAST_EXPECT(env.
balance(bob, usd) == preBobUSD);
1037 BEAST_EXPECT(
issuerBalance(env, gw, usd) == outstandingUSD);
1045 using namespace jtx;
1048 auto const alice =
Account(
"alice");
1049 auto const bob =
Account(
"bob");
1050 auto const carol =
Account(
"carol");
1051 auto const gw =
Account{
"gateway"};
1052 auto const usd = gw[
"USD"];
1056 Env env{*
this, features};
1057 env.
fund(
XRP(5000), alice, bob, carol, gw);
1058 env(
fset(gw, asfAllowTrustLineLocking));
1060 env.
trust(usd(10'000), alice, bob, carol);
1062 env(
pay(gw, alice, usd(5000)));
1063 env(
pay(gw, bob, usd(5000)));
1064 env(
pay(gw, carol, usd(5000)));
1066 auto const aseq = env.
seq(alice);
1067 auto const bseq = env.
seq(bob);
1167 Env env{*
this, features};
1168 env.
fund(
XRP(5000), alice, bob, carol, gw);
1169 env(
fset(gw, asfAllowTrustLineLocking));
1171 env.
trust(usd(10'000), alice, bob, carol);
1173 env(
pay(gw, alice, usd(5000)));
1174 env(
pay(gw, bob, usd(5000)));
1175 env(
pay(gw, carol, usd(5000)));
1177 auto const aseq = env.
seq(alice);
1178 auto const bseq = env.
seq(bob);
1299 testcase(
"IOU Metadata to issuer");
1301 Env env{*
this, features};
1302 env.
fund(
XRP(5000), alice, carol, gw);
1303 env(
fset(gw, asfAllowTrustLineLocking));
1305 env.
trust(usd(10'000), alice, carol);
1307 env(
pay(gw, alice, usd(5000)));
1308 env(
pay(gw, carol, usd(5000)));
1310 auto const aseq = env.
seq(alice);
1373 struct TestAccountData
1387 .hasTrustline =
false,
1393 .hasTrustline =
false,
1399 .hasTrustline =
false,
1405 .hasTrustline =
false,
1411 .hasTrustline =
true,
1417 .hasTrustline =
true,
1423 .hasTrustline =
true,
1429 .hasTrustline =
true,
1433 for (
auto const& t :
tests)
1435 Env env{*
this, features};
1436 auto const baseFee = env.
current()->fees().base;
1437 auto const usd = t.gw[
"USD"];
1438 env.
fund(
XRP(5000), t.src, t.dst, t.gw);
1439 env(
fset(t.gw, asfAllowTrustLineLocking));
1444 env.
trust(usd(100'000), t.src, t.dst);
1448 env.
trust(usd(100'000), t.src);
1452 env(
pay(t.gw, t.src, usd(10'000)));
1454 env(
pay(t.gw, t.dst, usd(10'000)));
1458 auto const seq1 = env.
seq(t.src);
1459 auto const delta = usd(1'000);
1463 Fee(baseFee * 150));
1467 auto const preSrc = env.
balance(t.src, usd);
1468 auto const preDst = env.
balance(t.dst, usd);
1473 Fee(baseFee * 150));
1476 BEAST_EXPECT(env.
balance(t.src, usd) == preSrc);
1477 BEAST_EXPECT(env.
balance(t.dst, usd) == preDst + delta);
1488 struct TestAccountData
1497 auto const gw =
Account{
"gateway"};
1498 auto const alice =
Account{
"alice"};
1499 Env env{*
this, features};
1500 auto const baseFee = env.
current()->fees().base;
1501 auto const usd = gw[
"USD"];
1502 env.
fund(
XRP(5000), alice, gw);
1503 env(
fset(gw, asfAllowTrustLineLocking));
1505 env.
trust(usd(100'000), alice);
1508 env(
pay(gw, alice, usd(10'000)));
1522 {.src =
Account(
"alice2"), .dst =
Account{
"gw0"}, .hasTrustline =
true},
1524 {.src =
Account(
"carol0"), .dst =
Account{
"gw1"}, .hasTrustline =
true},
1526 {.src =
Account(
"dan1"), .dst =
Account{
"gw0"}, .hasTrustline =
true},
1528 {.src =
Account(
"bob0"), .dst =
Account{
"gw1"}, .hasTrustline =
true},
1532 for (
auto const& t : gwDstTests)
1534 Env env{*
this, features};
1535 auto const baseFee = env.
current()->fees().base;
1536 auto const usd = t.dst[
"USD"];
1537 env.
fund(
XRP(5000), t.dst, t.src);
1538 env(
fset(t.dst, asfAllowTrustLineLocking));
1541 env.
trust(usd(100'000), t.src);
1544 env(
pay(t.dst, t.src, usd(10'000)));
1548 auto const seq1 = env.
seq(t.src);
1549 auto const preSrc = env.
balance(t.src, usd);
1553 Fee(baseFee * 150));
1560 Fee(baseFee * 150));
1562 auto const preAmount = 10'000;
1563 BEAST_EXPECT(preSrc == usd(preAmount));
1564 auto const postAmount = 9000;
1565 BEAST_EXPECT(env.
balance(t.src, usd) == usd(postAmount));
1566 BEAST_EXPECT(env.
balance(t.dst, usd) == usd(0));
1571 auto const gw =
Account{
"gateway"};
1572 auto const usd = gw[
"USD"];
1573 Env env{*
this, features};
1574 auto const baseFee = env.
current()->fees().base;
1576 env(
fset(gw, asfAllowTrustLineLocking));
1596 auto const alice =
Account(
"alice");
1597 auto const bob =
Account(
"bob");
1598 auto const carol =
Account(
"carol");
1599 auto const gw =
Account{
"gateway"};
1600 auto const usd = gw[
"USD"];
1604 Env env{*
this, features};
1605 auto const baseFee = env.
current()->fees().base;
1606 env.
fund(
XRP(10'000), alice, bob, gw);
1607 env(
fset(gw, asfAllowTrustLineLocking));
1608 env(
rate(gw, 1.25));
1610 env.
trust(usd(100'000), alice);
1611 env.
trust(usd(100'000), bob);
1613 env(
pay(gw, alice, usd(10'000)));
1614 env(
pay(gw, bob, usd(10'000)));
1618 auto const preAlice = env.
balance(alice, usd);
1619 auto const seq1 = env.
seq(alice);
1620 auto const delta = usd(125);
1624 Fee(baseFee * 150));
1633 Fee(baseFee * 150));
1636 BEAST_EXPECT(env.
balance(alice, usd) == preAlice - delta);
1637 BEAST_EXPECT(env.
balance(bob, usd) == usd(10'100));
1641 Env env{*
this, features};
1642 auto const baseFee = env.
current()->fees().base;
1643 env.
fund(
XRP(10'000), alice, bob, gw);
1644 env(
fset(gw, asfAllowTrustLineLocking));
1645 env(
rate(gw, 1.25));
1647 env.
trust(usd(100'000), alice);
1648 env.
trust(usd(100'000), bob);
1650 env(
pay(gw, alice, usd(10'000)));
1651 env(
pay(gw, bob, usd(10'000)));
1655 auto const preAlice = env.
balance(alice, usd);
1656 auto const seq1 = env.
seq(alice);
1657 auto const delta = usd(125);
1661 Fee(baseFee * 150));
1667 env(
rate(gw, 1.26));
1674 Fee(baseFee * 150));
1677 BEAST_EXPECT(env.
balance(alice, usd) == preAlice - delta);
1678 BEAST_EXPECT(env.
balance(bob, usd) == usd(10'100));
1683 Env env{*
this, features};
1684 auto const baseFee = env.
current()->fees().base;
1685 env.
fund(
XRP(10'000), alice, bob, gw);
1686 env(
fset(gw, asfAllowTrustLineLocking));
1687 env(
rate(gw, 1.25));
1689 env.
trust(usd(100'000), alice);
1690 env.
trust(usd(100'000), bob);
1692 env(
pay(gw, alice, usd(10'000)));
1693 env(
pay(gw, bob, usd(10'000)));
1697 auto const preAlice = env.
balance(alice, usd);
1698 auto const seq1 = env.
seq(alice);
1699 auto const delta = usd(125);
1703 Fee(baseFee * 150));
1709 env(
rate(gw, 1.00));
1716 Fee(baseFee * 150));
1719 BEAST_EXPECT(env.
balance(alice, usd) == preAlice - delta);
1720 BEAST_EXPECT(env.
balance(bob, usd) == usd(10125));
1725 Env env{*
this, features};
1726 auto const baseFee = env.
current()->fees().base;
1727 env.
fund(
XRP(10'000), alice, bob, gw);
1728 env(
fset(gw, asfAllowTrustLineLocking));
1729 env(
rate(gw, 1.25));
1731 env.
trust(usd(100'000), alice);
1732 env.
trust(usd(100'000), bob);
1734 env(
pay(gw, alice, usd(10'000)));
1735 env(
pay(gw, bob, usd(10'000)));
1739 auto const preAlice = env.
balance(alice, usd);
1740 auto const seq1 = env.
seq(alice);
1741 auto const delta = usd(125);
1751 env(
rate(gw, 1.00));
1758 BEAST_EXPECT(env.
balance(alice, usd) == preAlice);
1759 BEAST_EXPECT(env.
balance(bob, usd) == usd(10000));
1770 auto const alice =
Account(
"alice");
1771 auto const bob =
Account(
"bob");
1772 auto const gw =
Account{
"gateway"};
1773 auto const usd = gw[
"USD"];
1777 Env env{*
this, features};
1778 auto const baseFee = env.
current()->fees().base;
1779 env.
fund(
XRP(1'000), alice, bob, gw);
1780 env(
fset(gw, asfAllowTrustLineLocking));
1782 env.
trust(usd(10'000), alice, bob);
1784 env(
pay(gw, alice, usd(1'000)));
1785 env(
pay(gw, bob, usd(1'000)));
1789 auto seq1 = env.
seq(alice);
1790 auto const delta = usd(125);
1794 Fee(baseFee * 150));
1798 auto const preBobLimit = env.
limit(bob, usd);
1802 Fee(baseFee * 150));
1804 auto const postBobLimit = env.
limit(bob, usd);
1806 BEAST_EXPECT(postBobLimit == preBobLimit);
1817 auto const alice =
Account(
"alice");
1818 auto const bob =
Account(
"bob");
1819 auto const carol =
Account(
"carol");
1820 auto const gw =
Account{
"gateway"};
1821 auto const usd = gw[
"USD"];
1823 auto const aliceUSD = alice[
"USD"];
1824 auto const bobUSD = bob[
"USD"];
1826 Env env{*
this, features};
1827 auto const baseFee = env.
current()->fees().base;
1828 env.
fund(
XRP(1'000), alice, bob, gw);
1829 env(
fset(gw, asfAllowTrustLineLocking));
1830 env(
fset(gw, asfRequireAuth));
1833 env(
trust(alice, usd(10'000)));
1834 env(
trust(bob, usd(10'000)));
1836 env(
pay(gw, alice, usd(1'000)));
1840 auto seq1 = env.
seq(alice);
1841 auto const delta = usd(125);
1851 env(
trust(bob, usd(10'000)));
1853 env(
pay(gw, bob, usd(1'000)));
1857 seq1 = env.
seq(alice);
1861 Fee(baseFee * 150));
1868 Fee(baseFee * 150));
1879 auto const alice =
Account(
"alice");
1880 auto const bob =
Account(
"bob");
1881 auto const carol =
Account(
"carol");
1882 auto const gw =
Account{
"gateway"};
1883 auto const usd = gw[
"USD"];
1887 Env env{*
this, features};
1888 auto const baseFee = env.
current()->fees().base;
1889 env.
fund(
XRP(10'000), alice, bob, gw);
1890 env(
fset(gw, asfAllowTrustLineLocking));
1892 env.
trust(usd(100'000), alice);
1893 env.
trust(usd(100'000), bob);
1895 env(
pay(gw, alice, usd(10'000)));
1896 env(
pay(gw, bob, usd(10'000)));
1898 env(
fset(gw, asfGlobalFreeze));
1902 auto seq1 = env.
seq(alice);
1903 auto const delta = usd(125);
1914 env(
fclear(gw, asfGlobalFreeze));
1918 seq1 = env.
seq(alice);
1922 Fee(baseFee * 150));
1926 env(
fset(gw, asfGlobalFreeze));
1933 Fee(baseFee * 150));
1937 env(
fclear(gw, asfGlobalFreeze));
1941 seq1 = env.
seq(alice);
1945 Fee(baseFee * 150));
1949 env(
fset(gw, asfGlobalFreeze));
1960 Env env{*
this, features};
1961 auto const baseFee = env.
current()->fees().base;
1962 env.
fund(
XRP(10'000), alice, bob, gw);
1963 env(
fset(gw, asfAllowTrustLineLocking));
1965 env(
trust(alice, usd(100'000)));
1966 env(
trust(bob, usd(100'000)));
1968 env(
pay(gw, alice, usd(10'000)));
1969 env(
pay(gw, bob, usd(10'000)));
1973 env(
trust(gw, usd(10'000), alice, tfSetFreeze));
1977 auto seq1 = env.
seq(alice);
1978 auto const delta = usd(125);
1989 env(
trust(gw, usd(10'000), alice, tfClearFreeze));
1993 seq1 = env.
seq(alice);
1997 Fee(baseFee * 150));
2001 env(
trust(gw, usd(10'000), bob, tfSetFreeze));
2008 Fee(baseFee * 150));
2012 env(
trust(gw, usd(10'000), alice, tfClearFreeze));
2013 env(
trust(gw, usd(10'000), bob, tfClearFreeze));
2017 seq1 = env.
seq(alice);
2021 Fee(baseFee * 150));
2025 env(
trust(gw, usd(10'000), bob, tfSetFreeze));
2036 Env env{*
this, features};
2037 auto const baseFee = env.
current()->fees().base;
2038 env.
fund(
XRP(10'000), alice, bob, gw);
2039 env(
fset(gw, asfAllowTrustLineLocking));
2041 env(
trust(alice, usd(100'000)));
2042 env(
trust(bob, usd(100'000)));
2044 env(
pay(gw, alice, usd(10'000)));
2045 env(
pay(gw, bob, usd(10'000)));
2049 env(
trust(gw, usd(10'000), alice, tfSetFreeze | tfSetDeepFreeze));
2053 auto seq1 = env.
seq(alice);
2054 auto const delta = usd(125);
2065 env(
trust(gw, usd(10'000), alice, tfClearFreeze | tfClearDeepFreeze));
2069 seq1 = env.
seq(alice);
2073 Fee(baseFee * 150));
2077 env(
trust(gw, usd(10'000), bob, tfSetFreeze | tfSetDeepFreeze));
2089 env(
trust(gw, usd(10'000), alice, tfClearFreeze | tfClearDeepFreeze));
2090 env(
trust(gw, usd(10'000), bob, tfClearFreeze | tfClearDeepFreeze));
2094 seq1 = env.
seq(alice);
2098 Fee(baseFee * 150));
2102 env(
trust(gw, usd(10'000), bob, tfSetFreeze | tfSetDeepFreeze));
2113 testcase(
"IOU Insufficient Funds");
2117 auto const alice =
Account(
"alice");
2118 auto const bob =
Account(
"bob");
2119 auto const carol =
Account(
"carol");
2120 auto const gw =
Account{
"gateway"};
2121 auto const usd = gw[
"USD"];
2125 Env env{*
this, features};
2126 auto const baseFee = env.
current()->fees().base;
2127 env.
fund(
XRP(10'000), alice, bob, gw);
2128 env(
fset(gw, asfAllowTrustLineLocking));
2130 env.
trust(usd(100'000), alice);
2131 env.
trust(usd(100'000), bob);
2133 env(
pay(gw, alice, usd(10'000)));
2134 env(
pay(gw, bob, usd(10'000)));
2138 auto const delta = usd(1'000);
2142 Fee(baseFee * 150));
2149 Env env{*
this, features};
2150 auto const baseFee = env.
current()->fees().base;
2151 env.
fund(
XRP(10'000), alice, bob, gw);
2152 env(
fset(gw, asfAllowTrustLineLocking));
2154 env.
trust(usd(100'000), alice);
2155 env.
trust(usd(100'000), bob);
2157 env(
pay(gw, alice, usd(10'000)));
2158 env(
pay(gw, bob, usd(10'000)));
2161 auto const delta = usd(1'000);
2165 Fee(baseFee * 150));
2184 auto const alice =
Account(
"alice");
2185 auto const bob =
Account(
"bob");
2186 auto const gw =
Account{
"gateway"};
2187 auto const usd = gw[
"USD"];
2191 Env env(*
this, features);
2192 auto const baseFee = env.
current()->fees().base;
2193 env.
fund(
XRP(10'000), alice, bob, gw);
2194 env(
fset(gw, asfAllowTrustLineLocking));
2196 env.
trust(usd(100000000000000000), alice);
2197 env.
trust(usd(100000000000000000), bob);
2199 env(
pay(gw, alice, usd(10000000000000000)));
2200 env(
pay(gw, bob, usd(1)));
2203 bool const largeMantissa =
2204 features[featureSingleAssetVault] || features[featureLendingProtocol];
2214 auto const seq1 = env.
seq(alice);
2219 Fee(baseFee * 150));
2226 Fee(baseFee * 150));
2236 using namespace jtx;
2239 for (
bool const withTokenEscrow : {
false,
true})
2241 auto const amend = withTokenEscrow ? features : features - featureTokenEscrow;
2242 Env env{*
this, amend};
2243 auto const baseFee = env.
current()->fees().base;
2244 auto const alice =
Account(
"alice");
2245 auto const bob =
Account(
"bob");
2246 auto const gw =
Account(
"gw");
2249 MPTTester mptGw(env, gw, {.holders = {alice}});
2251 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2252 mptGw.authorize({.account = alice});
2253 auto const mpt = mptGw[
"MPT"];
2254 env(
pay(gw, alice, mpt(10'000)));
2260 auto const seq1 = env.
seq(alice);
2273 auto const seq2 = env.
seq(alice);
2293 for (
bool const withMPT : {
true,
false})
2295 auto const amend = withMPT ? features : features - featureMPTokensV1;
2296 Env env{*
this, amend};
2297 auto const baseFee = env.
current()->fees().base;
2298 auto const alice =
Account(
"alice");
2299 auto const bob =
Account(
"bob");
2300 auto const gw =
Account(
"gw");
2301 env.
fund(
XRP(1'000), alice, bob, gw);
2305 jv[jss::Amount][jss::mpt_issuance_id] =
2306 "00000004A407AF5856CCF3C42619DAA925813FC955C72983";
2307 jv[jss::Amount][jss::value] =
"-1";
2320 Env env{*
this, features};
2321 auto const baseFee = env.
current()->fees().base;
2322 auto const alice =
Account(
"alice");
2323 auto const bob =
Account(
"bob");
2324 auto const gw =
Account(
"gw");
2326 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2328 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2329 mptGw.authorize({.account = alice});
2330 mptGw.authorize({.account = bob});
2331 auto const mpt = mptGw[
"MPT"];
2332 env(
pay(gw, alice, mpt(10'000)));
2333 env(
pay(gw, bob, mpt(10'000)));
2354 Env env{*
this, features};
2355 auto const baseFee = env.
current()->fees().base;
2356 auto const alice =
Account(
"alice");
2357 auto const gw =
Account(
"gw");
2359 MPTTester mptGw(env, gw, {.holders = {alice}});
2361 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2362 mptGw.authorize({.account = alice});
2363 auto const mpt = mptGw[
"MPT"];
2364 env(
pay(gw, alice, mpt(10'000)));
2377 Env env{*
this, features};
2378 auto const baseFee = env.
current()->fees().base;
2379 auto const alice =
Account(
"alice");
2380 auto const bob =
Account(
"bob");
2381 auto const gw =
Account(
"gw");
2382 env.
fund(
XRP(10'000), alice, bob, gw);
2387 jv[jss::Amount][jss::mpt_issuance_id] =
2388 "00000004A407AF5856CCF3C42619DAA925813FC955C72983";
2399 Env env{*
this, features};
2400 auto const baseFee = env.
current()->fees().base;
2401 auto const alice =
Account(
"alice");
2402 auto const bob =
Account(
"bob");
2403 auto const gw =
Account(
"gw");
2405 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2406 mptGw.
create({.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer});
2407 mptGw.authorize({.account = alice});
2408 mptGw.authorize({.account = bob});
2409 auto const mpt = mptGw[
"MPT"];
2410 env(
pay(gw, alice, mpt(10'000)));
2411 env(
pay(gw, bob, mpt(10'000)));
2424 Env env{*
this, features};
2425 auto const baseFee = env.
current()->fees().base;
2426 auto const alice =
Account(
"alice");
2427 auto const bob =
Account(
"bob");
2428 auto const gw =
Account(
"gw");
2430 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2432 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2433 auto const mpt = mptGw[
"MPT"];
2445 Env env{*
this, features};
2446 auto const baseFee = env.
current()->fees().base;
2447 auto const alice =
Account(
"alice");
2448 auto const bob =
Account(
"bob");
2449 auto const gw =
Account(
"gw");
2451 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2455 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTRequireAuth});
2456 mptGw.authorize({.account = alice});
2457 mptGw.authorize({.account = gw, .holder = alice});
2458 auto const mpt = mptGw[
"MPT"];
2459 env(
pay(gw, alice, mpt(10'000)));
2463 mptGw.authorize({.account = gw, .holder = alice, .flags = tfMPTUnauthorize});
2475 Env env{*
this, features};
2476 auto const baseFee = env.
current()->fees().base;
2477 auto const alice =
Account(
"alice");
2478 auto const bob =
Account(
"bob");
2479 auto const gw =
Account(
"gw");
2481 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2485 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTRequireAuth});
2486 mptGw.authorize({.account = alice});
2487 mptGw.authorize({.account = gw, .holder = alice});
2488 mptGw.authorize({.account = bob});
2489 mptGw.authorize({.account = gw, .holder = bob});
2490 auto const mpt = mptGw[
"MPT"];
2491 env(
pay(gw, alice, mpt(10'000)));
2492 env(
pay(gw, bob, mpt(10'000)));
2496 mptGw.authorize({.account = gw, .holder = bob, .flags = tfMPTUnauthorize});
2508 Env env{*
this, features};
2509 auto const baseFee = env.
current()->fees().base;
2510 auto const alice =
Account(
"alice");
2511 auto const bob =
Account(
"bob");
2512 auto const gw =
Account(
"gw");
2514 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2518 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTCanLock});
2519 mptGw.authorize({.account = alice});
2520 mptGw.authorize({.account = bob});
2521 auto const mpt = mptGw[
"MPT"];
2522 env(
pay(gw, alice, mpt(10'000)));
2523 env(
pay(gw, bob, mpt(10'000)));
2527 mptGw.set({.account = gw, .holder = alice, .flags = tfMPTLock});
2539 Env env{*
this, features};
2540 auto const baseFee = env.
current()->fees().base;
2541 auto const alice =
Account(
"alice");
2542 auto const bob =
Account(
"bob");
2543 auto const gw =
Account(
"gw");
2545 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2549 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTCanLock});
2550 mptGw.authorize({.account = alice});
2551 mptGw.authorize({.account = bob});
2552 auto const mpt = mptGw[
"MPT"];
2553 env(
pay(gw, alice, mpt(10'000)));
2554 env(
pay(gw, bob, mpt(10'000)));
2558 mptGw.set({.account = gw, .holder = bob, .flags = tfMPTLock});
2570 Env env{*
this, features};
2571 auto const baseFee = env.
current()->fees().base;
2572 auto const alice =
Account(
"alice");
2573 auto const bob =
Account(
"bob");
2574 auto const gw =
Account(
"gw");
2576 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2577 mptGw.
create({.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow});
2578 mptGw.authorize({.account = alice});
2579 mptGw.authorize({.account = bob});
2580 auto const mpt = mptGw[
"MPT"];
2581 env(
pay(gw, alice, mpt(10'000)));
2582 env(
pay(gw, bob, mpt(10'000)));
2595 Env env{*
this, features};
2596 auto const baseFee = env.
current()->fees().base;
2597 auto const alice =
Account(
"alice");
2598 auto const bob =
Account(
"bob");
2599 auto const gw =
Account(
"gw");
2601 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2603 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2604 mptGw.authorize({.account = alice});
2605 mptGw.authorize({.account = bob});
2606 auto const mpt = mptGw[
"MPT"];
2607 env(
pay(gw, bob, mpt(10)));
2620 Env env{*
this, features};
2621 auto const baseFee = env.
current()->fees().base;
2622 auto const alice =
Account(
"alice");
2623 auto const bob =
Account(
"bob");
2624 auto const gw =
Account(
"gw");
2626 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2628 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2629 mptGw.authorize({.account = alice});
2630 mptGw.authorize({.account = bob});
2631 auto const mpt = mptGw[
"MPT"];
2632 env(
pay(gw, alice, mpt(10)));
2633 env(
pay(gw, bob, mpt(10)));
2654 Env env{*
this, features};
2655 auto const baseFee = env.
current()->fees().base;
2656 auto const alice =
Account(
"alice");
2657 auto const bob =
Account(
"bob");
2658 auto const gw =
Account(
"gw");
2660 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2664 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTRequireAuth});
2665 mptGw.authorize({.account = alice});
2666 mptGw.authorize({.account = gw, .holder = alice});
2667 mptGw.authorize({.account = bob});
2668 mptGw.authorize({.account = gw, .holder = bob});
2669 auto const mpt = mptGw[
"MPT"];
2670 env(
pay(gw, alice, mpt(10'000)));
2671 env(
pay(gw, bob, mpt(10'000)));
2674 auto const seq1 = env.
seq(alice);
2683 mptGw.authorize({.account = gw, .holder = bob, .flags = tfMPTUnauthorize});
2695 Env env{*
this, features};
2696 auto const baseFee = env.
current()->fees().base;
2697 auto const alice =
Account(
"alice");
2698 auto const bob =
Account(
"bob");
2699 env.
fund(
XRP(10'000), alice, bob);
2702 auto const seq1 = env.
seq(alice);
2708 sleNew->setAccountID(sfDestination, bob);
2709 sleNew->setFieldAmount(sfAmount, amt);
2725 Env env{*
this, features};
2726 auto const baseFee = env.
current()->fees().base;
2727 auto const alice =
Account(
"alice");
2728 auto const bob =
Account(
"bob");
2729 auto const gw =
Account(
"gw");
2731 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2735 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTCanLock});
2736 mptGw.authorize({.account = alice});
2737 mptGw.authorize({.account = bob});
2738 auto const mpt = mptGw[
"MPT"];
2739 env(
pay(gw, alice, mpt(10'000)));
2740 env(
pay(gw, bob, mpt(10'000)));
2743 auto const seq1 = env.
seq(alice);
2752 mptGw.set({.account = gw, .holder = bob, .flags = tfMPTLock});
2772 Env env{*
this, features};
2773 auto const baseFee = env.
current()->fees().base;
2774 auto const acctReserve = env.
current()->fees().reserve;
2775 auto const incReserve = env.
current()->fees().increment;
2777 auto const alice =
Account(
"alice");
2778 auto const bob =
Account(
"bob");
2779 auto const gw =
Account(
"gw");
2780 env.
fund(acctReserve + (incReserve - 1), bob);
2783 MPTTester mptGw(env, gw, {.holders = {alice}});
2785 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2786 mptGw.authorize({.account = alice});
2787 auto const mpt = mptGw[
"MPT"];
2788 env(
pay(gw, alice, mpt(10'000)));
2791 auto const seq1 = env.
seq(alice);
2809 Env env{*
this, features};
2810 auto const baseFee = env.
current()->fees().base;
2811 auto const alice =
Account(
"alice");
2812 auto const bob =
Account(
"bob");
2813 auto const gw =
Account(
"gw");
2817 MPTTester mptGw(env, gw, {.holders = {alice}});
2819 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2820 mptGw.authorize({.account = alice});
2821 auto const mpt = mptGw[
"MPT"];
2822 env(
pay(gw, alice, mpt(10'000)));
2825 auto const seq1 = env.
seq(alice);
2843 Env env{*
this, features};
2844 auto const baseFee = env.
current()->fees().base;
2845 auto const alice =
Account(
"alice");
2846 auto const bob =
Account(
"bob");
2847 auto const carol =
Account(
"carol");
2848 auto const gw =
Account(
"gw");
2849 env.
fund(
XRP(10'000), bob, carol);
2852 MPTTester mptGw(env, gw, {.holders = {alice}});
2854 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2855 mptGw.authorize({.account = alice});
2856 auto const mpt = mptGw[
"MPT"];
2857 env(
pay(gw, alice, mpt(10'000)));
2860 auto const seq1 = env.
seq(alice);
2886 Env env{*
this, features};
2887 auto const baseFee = env.
current()->fees().base;
2888 auto const alice =
Account(
"alice");
2889 auto const bob =
Account(
"bob");
2890 auto const gw =
Account(
"gw");
2892 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2896 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTRequireAuth});
2897 mptGw.authorize({.account = alice});
2898 mptGw.authorize({.account = gw, .holder = alice});
2899 mptGw.authorize({.account = bob});
2900 mptGw.authorize({.account = gw, .holder = bob});
2901 auto const mpt = mptGw[
"MPT"];
2902 env(
pay(gw, alice, mpt(10'000)));
2903 env(
pay(gw, bob, mpt(10'000)));
2906 auto const seq1 = env.
seq(alice);
2915 mptGw.authorize({.account = gw, .holder = alice, .flags = tfMPTUnauthorize});
2923 Env env{*
this, features};
2924 auto const baseFee = env.
current()->fees().base;
2925 auto const alice =
Account(
"alice");
2926 auto const bob =
Account(
"bob");
2927 env.
fund(
XRP(10'000), alice, bob);
2929 auto const seq1 = env.
seq(alice);
2935 sleNew->setAccountID(sfDestination, bob);
2936 sleNew->setFieldAmount(sfAmount, amt);
2952 using namespace jtx;
2955 Env env{*
this, features};
2956 auto const baseFee = env.
current()->fees().base;
2957 auto const alice =
Account(
"alice");
2958 auto const bob =
Account(
"bob");
2959 auto const carol =
Account(
"carol");
2960 auto const gw =
Account(
"gw");
2963 MPTTester mptGw(env, gw, {.holders = {alice, carol}});
2965 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2966 mptGw.authorize({.account = alice});
2967 mptGw.authorize({.account = carol});
2968 auto const mpt = mptGw[
"MPT"];
2969 env(
pay(gw, alice, mpt(10'000)));
2970 env(
pay(gw, carol, mpt(10'000)));
2973 auto outstandingMPT = env.
balance(gw, mpt);
2976 auto const seq1 = env.
seq(alice);
2978 auto const preAliceMPT = env.
balance(alice, mpt);
2979 auto const preBobMPT = env.
balance(bob, mpt);
2987 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1'000));
2988 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == 1'000);
2989 BEAST_EXPECT(env.
balance(bob, mpt) == preBobMPT);
2991 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
2995 auto const preAliceMPT = env.
balance(alice, mpt);
2996 auto const preBobMPT = env.
balance(bob, mpt);
3004 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT);
3006 BEAST_EXPECT(env.
balance(bob, mpt) == preBobMPT + mpt(1'000));
3008 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3013 auto const seq2 = env.
seq(alice);
3015 auto const preAliceMPT = env.
balance(alice, mpt);
3016 auto const preBobMPT = env.
balance(bob, mpt);
3025 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1'000));
3026 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == 1'000);
3027 BEAST_EXPECT(env.
balance(bob, mpt) == preBobMPT);
3029 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3033 auto const preAliceMPT = env.
balance(alice, mpt);
3034 auto const preBobMPT = env.
balance(bob, mpt);
3038 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT + mpt(1'000));
3040 BEAST_EXPECT(env.
balance(bob, mpt) == preBobMPT);
3042 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3048 auto const seq = env.
seq(alice);
3049 auto const preAliceMPT = env.
balance(alice, mpt);
3057 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1'000));
3058 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == 1'000);
3059 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3069 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT);
3071 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3077 auto const seq = env.
seq(alice);
3078 auto const preAliceMPT = env.
balance(alice, mpt);
3087 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1'000));
3088 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == 1'000);
3089 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3095 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT);
3097 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3103 auto const preAliceMPT = env.
balance(alice, mpt);
3104 auto const preBobMPT = env.
balance(bob, mpt);
3105 auto const preCarolMPT = env.
balance(carol, mpt);
3120 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1'000));
3121 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == 1'000);
3122 BEAST_EXPECT(env.
balance(bob, mpt) == preBobMPT);
3124 BEAST_EXPECT(env.
balance(carol, mpt) == preCarolMPT - mpt(1'000));
3125 BEAST_EXPECT(
mptEscrowed(env, carol, mpt) == 1'000);
3126 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3132 Env env{*
this, features};
3133 auto const baseFee = env.
current()->fees().base;
3134 auto const alice =
Account(
"alice");
3135 auto const bob =
Account(
"bob");
3136 auto const gw =
Account(
"gw");
3138 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
3140 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
3141 mptGw.authorize({.account = alice});
3142 mptGw.authorize({.account = bob});
3143 auto const mpt = mptGw[
"MPT"];
3147 auto const preAliceMPT = env.
balance(alice, mpt);
3148 auto const preBobMPT = env.
balance(bob, mpt);
3149 auto const outstandingMPT = env.
balance(gw, mpt);
3151 auto const seq1 = env.
seq(alice);
3155 Fee(baseFee * 150));
3158 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1));
3160 BEAST_EXPECT(env.
balance(bob, mpt) == preBobMPT);
3162 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3172 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1));
3176 BEAST_EXPECT(env.
balance(bob, mpt) == preBobMPT + mpt(1));
3178 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3186 Env env{*
this, features};
3187 auto const baseFee = env.
current()->fees().base;
3188 auto const alice =
Account(
"alice");
3189 auto const bob =
Account(
"bob");
3190 auto const gw =
Account(
"gw");
3192 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
3194 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
3195 mptGw.authorize({.account = alice});
3196 mptGw.authorize({.account = bob});
3197 auto const mpt = mptGw[
"MPT"];
3201 auto const preAliceMPT = env.
balance(alice, mpt);
3202 auto const preBobMPT = env.
balance(bob, mpt);
3203 auto const outstandingMPT = env.
balance(gw, mpt);
3206 auto const seq1 = env.
seq(alice);
3210 Fee(baseFee * 150));
3214 auto const seq2 = env.
seq(alice);
3218 Fee(baseFee * 150));
3223 BEAST_EXPECT(env.
balance(bob, mpt) == preBobMPT);
3225 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3246 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3254 using namespace jtx;
3257 auto const alice =
Account(
"alice");
3258 auto const bob =
Account(
"bob");
3259 auto const carol =
Account(
"carol");
3260 auto const gw =
Account{
"gateway"};
3264 Env env{*
this, features};
3265 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
3267 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
3268 mptGw.authorize({.account = alice});
3269 mptGw.authorize({.account = bob});
3270 auto const mpt = mptGw[
"MPT"];
3271 env(
pay(gw, alice, mpt(10'000)));
3272 env(
pay(gw, bob, mpt(10'000)));
3274 auto const aseq = env.
seq(alice);
3275 auto const bseq = env.
seq(bob);
3356 Env env{*
this, features};
3357 MPTTester mptGw(env, gw, {.holders = {alice, bob, carol}});
3359 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
3360 mptGw.authorize({.account = alice});
3361 mptGw.authorize({.account = bob});
3362 mptGw.authorize({.account = carol});
3363 auto const mpt = mptGw[
"MPT"];
3364 env(
pay(gw, alice, mpt(10'000)));
3365 env(
pay(gw, bob, mpt(10'000)));
3366 env(
pay(gw, carol, mpt(10'000)));
3368 auto const aseq = env.
seq(alice);
3369 auto const bseq = env.
seq(bob);
3472 Env env{*
this, features};
3473 auto const baseFee = env.
current()->fees().base;
3474 auto const alice =
Account(
"alice");
3475 auto const gw =
Account(
"gw");
3477 MPTTester mptGw(env, gw, {.holders = {alice}});
3479 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
3480 mptGw.authorize({.account = alice});
3481 auto const mpt = mptGw[
"MPT"];
3482 env(
pay(gw, alice, mpt(10'000)));
3486 auto const seq1 = env.
seq(alice);
3487 auto const preAliceMPT = env.
balance(alice, mpt);
3488 auto const preOutstanding = env.
balance(gw, mpt);
3490 BEAST_EXPECT(preOutstanding == mpt(-10'000));
3491 BEAST_EXPECT(preEscrowed == 0);
3496 Fee(baseFee * 150));
3499 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1'000));
3500 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == 1'000);
3501 BEAST_EXPECT(env.
balance(gw, mpt) == preOutstanding);
3508 Fee(baseFee * 150));
3511 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1'000));
3513 BEAST_EXPECT(env.
balance(gw, mpt) == preOutstanding + mpt(1'000));
3525 auto const alice =
Account(
"alice");
3526 auto const bob =
Account(
"bob");
3527 auto const carol =
Account(
"carol");
3528 auto const gw =
Account{
"gateway"};
3529 auto const usd = gw[
"USD"];
3533 Env env{*
this, features};
3534 auto const baseFee = env.
current()->fees().base;
3535 auto const alice =
Account(
"alice");
3536 auto const bob =
Account(
"bob");
3537 auto const gw =
Account(
"gw");
3539 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
3541 {.transferFee = 25000,
3544 .flags = tfMPTCanEscrow | tfMPTCanTransfer});
3545 mptGw.authorize({.account = alice});
3546 mptGw.authorize({.account = bob});
3547 auto const mpt = mptGw[
"MPT"];
3548 env(
pay(gw, alice, mpt(10'000)));
3549 env(
pay(gw, bob, mpt(10'000)));
3553 auto const preAlice = env.
balance(alice, mpt);
3554 auto const seq1 = env.
seq(alice);
3555 auto const delta = mpt(125);
3559 Fee(baseFee * 150));
3564 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == 125);
3566 BEAST_EXPECT(env.
balance(gw, mpt) == mpt(-20'000));
3572 Fee(baseFee * 150));
3575 BEAST_EXPECT(env.
balance(alice, mpt) == preAlice - delta);
3576 BEAST_EXPECT(env.
balance(bob, mpt) == mpt(10'100));
3578 auto const escrowedWithFix = env.
current()->rules().enabled(fixTokenEscrowV1) ? 0 : 25;
3579 auto const outstandingWithFix =
3580 env.
current()->rules().enabled(fixTokenEscrowV1) ? mpt(19'975) : mpt(20'000);
3581 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == escrowedWithFix);
3583 BEAST_EXPECT(env.
balance(gw, mpt) == -outstandingWithFix);
3588 Env env{*
this, features};
3589 auto const baseFee = env.
current()->fees().base;
3590 auto const alice =
Account(
"alice");
3591 auto const bob =
Account(
"bob");
3592 auto const gw =
Account(
"gw");
3594 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
3596 {.transferFee = 25000,
3599 .flags = tfMPTCanEscrow | tfMPTCanTransfer});
3600 mptGw.authorize({.account = alice});
3601 mptGw.authorize({.account = bob});
3602 auto const mpt = mptGw[
"MPT"];
3603 env(
pay(gw, alice, mpt(10'000)));
3604 env(
pay(gw, bob, mpt(10'000)));
3608 auto const preAlice = env.
balance(alice, mpt);
3609 auto const preBob = env.
balance(bob, mpt);
3610 auto const seq1 = env.
seq(alice);
3611 auto const delta = mpt(125);
3616 Fee(baseFee * 150));
3625 BEAST_EXPECT(env.
balance(alice, mpt) == preAlice);
3626 BEAST_EXPECT(env.
balance(bob, mpt) == preBob);
3627 BEAST_EXPECT(env.
balance(gw, mpt) == mpt(-20'000));
3634 Env env{*
this, features};
3635 auto const baseFee = env.
current()->fees().base;
3636 auto const alice =
Account(
"alice");
3637 auto const bob =
Account(
"bob");
3638 auto const gw =
Account(
"gw");
3640 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
3642 {.transferFee = 25000,
3645 .flags = tfMPTCanEscrow | tfMPTCanTransfer});
3646 mptGw.authorize({.account = alice});
3647 mptGw.authorize({.account = bob});
3648 auto const mpt = mptGw[
"MPT"];
3649 env(
pay(gw, alice, mpt(10'000)));
3650 env(
pay(gw, bob, mpt(10'000)));
3654 auto const preAlice = env.
balance(alice, mpt);
3655 auto const seq1 = env.
seq(alice);
3656 auto const delta = mpt(125);
3660 Fee(baseFee * 150));
3665 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == 125);
3667 BEAST_EXPECT(env.
balance(gw, mpt) == mpt(-20'000));
3673 Fee(baseFee * 150));
3676 BEAST_EXPECT(env.
balance(alice, mpt) == preAlice - delta);
3679 BEAST_EXPECT(env.
balance(gw, mpt) == mpt(-19'875));
3690 Env env{*
this, features};
3691 auto const baseFee = env.
current()->fees().base;
3692 auto const alice =
Account(
"alice");
3693 auto const bob =
Account(
"bob");
3694 auto const gw =
Account(
"gw");
3696 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
3700 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTRequireAuth});
3701 mptGw.authorize({.account = alice});
3702 mptGw.authorize({.account = gw, .holder = alice});
3703 mptGw.authorize({.account = bob});
3704 mptGw.authorize({.account = gw, .holder = bob});
3705 auto const mpt = mptGw[
"MPT"];
3706 env(
pay(gw, alice, mpt(10'000)));
3709 auto seq = env.
seq(alice);
3710 auto const delta = mpt(125);
3715 Fee(baseFee * 150));
3722 Fee(baseFee * 150));
3733 Env env{*
this, features};
3734 auto const baseFee = env.
current()->fees().base;
3735 auto const alice =
Account(
"alice");
3736 auto const bob =
Account(
"bob");
3737 auto const gw =
Account(
"gw");
3739 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
3743 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTCanLock});
3744 mptGw.authorize({.account = alice});
3745 mptGw.authorize({.account = bob});
3746 auto const mpt = mptGw[
"MPT"];
3747 env(
pay(gw, alice, mpt(10'000)));
3748 env(
pay(gw, bob, mpt(10'000)));
3752 auto seq1 = env.
seq(alice);
3757 Fee(baseFee * 150));
3761 mptGw.set({.account = gw, .holder = alice, .flags = tfMPTLock});
3762 mptGw.set({.account = gw, .holder = bob, .flags = tfMPTLock});
3784 Env env{*
this, features};
3785 auto const baseFee = env.
current()->fees().base;
3786 auto const alice =
Account(
"alice");
3787 auto const bob =
Account(
"bob");
3788 auto const gw =
Account(
"gw");
3790 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
3791 mptGw.
create({.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow});
3792 mptGw.authorize({.account = alice});
3793 mptGw.authorize({.account = bob});
3794 auto const mpt = mptGw[
"MPT"];
3795 env(
pay(gw, alice, mpt(10'000)));
3796 env(
pay(gw, bob, mpt(10'000)));
3811 auto seq = env.
seq(alice);
3815 Fee(baseFee * 150));
3822 Fee(baseFee * 150));
3829 auto seq = env.
seq(alice);
3834 Fee(baseFee * 150));
3852 Env env{*
this, features};
3853 auto const baseFee = env.
current()->fees().base;
3854 auto const alice =
Account(
"alice");
3855 auto const bob =
Account(
"bob");
3856 auto const gw =
Account(
"gw");
3858 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
3860 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
3861 mptGw.authorize({.account = alice});
3862 mptGw.authorize({.account = bob});
3863 auto const mpt = mptGw[
"MPT"];
3864 env(
pay(gw, alice, mpt(10'000)));
3865 env(
pay(gw, bob, mpt(10'000)));
3868 auto const seq1 = env.
seq(alice);
3872 Fee(baseFee * 150));
3876 env(
pay(alice, gw, mpt(9'990)));
3877 env(
pay(bob, gw, mpt(10'000)));
3878 BEAST_EXPECT(env.
balance(alice, mpt) == mpt(0));
3880 BEAST_EXPECT(env.
balance(bob, mpt) == mpt(0));
3882 BEAST_EXPECT(env.
balance(gw, mpt) == mpt(-10));
3883 mptGw.authorize({.account = bob, .flags = tfMPTUnauthorize});
3884 mptGw.destroy({.id = mptGw.issuanceID(), .ownerCount = 1, .err =
tecHAS_OBLIGATIONS});
3893 env(
pay(bob, gw, mpt(10)));
3894 mptGw.destroy({.id = mptGw.issuanceID(), .ownerCount = 0});
3899 Env env{*
this, features};
3900 auto const baseFee = env.
current()->fees().base;
3901 auto const alice =
Account(
"alice");
3902 auto const bob =
Account(
"bob");
3903 auto const gw =
Account(
"gw");
3907 MPTTester mptGw(env, gw, {.holders = {alice}});
3909 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
3910 mptGw.authorize({.account = alice});
3911 auto const mpt = mptGw[
"MPT"];
3912 env(
pay(gw, alice, mpt(10'000)));
3915 auto const seq1 = env.
seq(alice);
3923 env(
pay(alice, gw, mpt(9'990)));
3926 BEAST_EXPECT(env.
balance(alice, mpt) == mpt(0));
3938 BEAST_EXPECT(env.
balance(alice, mpt) == mpt(0));
3940 mptGw.authorize({.account = alice, .flags = tfMPTUnauthorize});
3994 {all - featureSingleAssetVault - featureLendingProtocol, all})
A generic endpoint for log messages.
TestcaseT testcase
Memberspace for declaring test cases.
Value removeMember(char const *key)
Remove and return the named member.
A class that simplifies iterating ledger directory pages.
ConstIterator begin() const
ConstIterator end() const
A currency issued by an account.
bool modify(modify_type const &f)
Modify the open ledger.
Writable ledger view that accumulates state and tx changes.
Discardable, editable view to a ledger.
virtual OpenLedger & getOpenLedger()=0
void insert(SLE::ref sle) override
Insert a new state SLE.
Immutable cryptographic account descriptor.
A transaction testing environment.
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
SLE::const_pointer le(Account const &account) const
Return an account root.
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
PrettyAmount limit(Account const &account, Issue const &issue) const
Returns the IOU limit on an account.
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
json::Value rpc(unsigned apiVersion, std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
PrettyAmount balance(Account const &account) const
Returns the XRP balance on an account.
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
std::shared_ptr< STObject const > meta()
Return metadata for the last JTx.
void memoize(Account const &account)
Associate AccountID with account.
void require(Args const &... args)
Check a set of requirements.
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
NetClock::time_point now()
Returns the current network time.
Converts to IOU Issue or STAmount.
Test helper for creating, mutating, and asserting MPT and confidential MPT ledger state.
void create(MPTCreate const &arg=MPTCreate{})
Converts to MPT Issue or STAmount.
xrpl::MPTID const & mpt() const
Match clear account flags.
Set the expected result code for a JTx The test will fail if the code doesn't match.
Keylet mptokenIssuance(std::uint32_t seq, AccountID const &issuer) noexcept
Keylet escrow(AccountID const &src, std::uint32_t seq) noexcept
An escrow entry.
Keylet ownerDir(AccountID const &id) noexcept
The root page of an account's directory.
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Keylet trustLine(AccountID const &id0, AccountID const &id1, Currency const ¤cy) noexcept
The index of a trust line for a given currency.
json::Value create(AccountID const &account, AccountID const &to, STAmount const &amount)
json::Value cancel(AccountID const &account, Account const &from, std::uint32_t seq)
auto const kCancelTime
Set the "CancelAfter" time tag on a JTx.
Rate rate(Env &env, Account const &account, std::uint32_t const &seq)
auto const kFinishTime
Set the "FinishAfter" time tag on a JTx.
std::array< std::uint8_t, 39 > const kCb2
json::Value finish(AccountID const &account, AccountID const &from, std::uint32_t seq)
std::array< std::uint8_t, 4 > const kFb1
std::array< std::uint8_t, 39 > const kCb1
json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
XrpT const XRP
Converts to XRP Issue or STAmount.
json::Value fclear(Account const &account, std::uint32_t off)
Remove account flag.
FeatureBitset testableAmendments()
json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
json::Value rate(Account const &account, double multiplier)
Set a transfer rate.
json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
STAmount amountFromString(Asset const &asset, std::string const &amount)
std::string to_string(BaseUInt< Bits, Tag > const &a)
Rate transferRate(ReadView const &view, AccountID const &issuer)
Returns IOU issuer transfer fee as Rate.
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
TERSubset< CanCvtToTER > TER
@ tecNO_LINE_INSUF_RESERVE
@ tecINSUFFICIENT_RESERVE
Currency const & badCurrency()
We deliberately disallow the currency that looks like "XRP" because too many people were using it ins...
constexpr std::uint64_t kMaxMpTokenAmount
The maximum amount of MPTokenIssuance.
MPTID makeMptID(std::uint32_t sequence, AccountID const &account)
void testMPTCreatePreclaim(FeatureBitset features)
void testMPTFinishDoApply(FeatureBitset features)
void testMPTMetaAndOwnership(FeatureBitset features)
void testIOUBalances(FeatureBitset features)
void testIOUCreatePreclaim(FeatureBitset features)
void testMPTGateway(FeatureBitset features)
void testMPTCanTransfer(FeatureBitset features)
void testIOUFinishPreclaim(FeatureBitset features)
static jtx::PrettyAmount issuerEscrowed(jtx::Env &env, jtx::Account const &account, Issue const &issue)
void run() override
Runs the suite.
void testIOUMetaAndOwnership(FeatureBitset features)
void testIOUPrecisionLoss(FeatureBitset features)
void testMPTLock(FeatureBitset features)
void testMPTCancelPreclaim(FeatureBitset features)
void testIOUEnablement(FeatureBitset features)
void testMPTBalances(FeatureBitset features)
static jtx::PrettyAmount issuerBalance(jtx::Env &env, jtx::Account const &account, Issue const &issue)
void testMPTRequireAuth(FeatureBitset features)
void testIOUFinishDoApply(FeatureBitset features)
void testIOUFreeze(FeatureBitset features)
void testMPTEnablement(FeatureBitset features)
static uint64_t mptEscrowed(jtx::Env const &env, jtx::Account const &account, jtx::MPT const &mpt)
void testIOUCancelPreclaim(FeatureBitset features)
void testIOUGateway(FeatureBitset features)
static uint64_t issuerMPTEscrowed(jtx::Env const &env, jtx::MPT const &mpt)
void testIOULimitAmount(FeatureBitset features)
void testIOUAllowLockingFlag(FeatureBitset features)
void testMPTCreatePreflight(FeatureBitset features)
void testIOULockedRate(FeatureBitset features)
void testMPTFinishPreclaim(FeatureBitset features)
void testIOUCancelDoApply(FeatureBitset features)
void testIOUInsufficientFunds(FeatureBitset features)
void testIOUWithFeats(FeatureBitset features)
void testMPTLockedRate(FeatureBitset features)
void testMPTWithFeats(FeatureBitset features)
void testIOUCreatePreflight(FeatureBitset features)
void testIOURequireAuth(FeatureBitset features)
void testMPTDestroy(FeatureBitset features)
void testIOURippleState(FeatureBitset features)
Represents an XRP, IOU, or MPT quantity This customizes the string conversion and supports XRP conver...