2#include <test/jtx/Account.h>
3#include <test/jtx/Env.h>
4#include <test/jtx/TestHelpers.h>
5#include <test/jtx/amount.h>
6#include <test/jtx/balance.h>
7#include <test/jtx/escrow.h>
8#include <test/jtx/fee.h>
9#include <test/jtx/flags.h>
10#include <test/jtx/mpt.h>
11#include <test/jtx/pay.h>
12#include <test/jtx/rate.h>
13#include <test/jtx/ter.h>
14#include <test/jtx/trust.h>
15#include <test/jtx/txflags.h>
17#include <xrpl/beast/unit_test/suite.h>
18#include <xrpl/beast/utility/Journal.h>
19#include <xrpl/core/ServiceRegistry.h>
20#include <xrpl/json/json_value.h>
21#include <xrpl/ledger/ApplyView.h>
22#include <xrpl/ledger/OpenView.h>
23#include <xrpl/ledger/Sandbox.h>
24#include <xrpl/protocol/AccountID.h>
25#include <xrpl/protocol/Feature.h>
26#include <xrpl/protocol/Indexes.h>
27#include <xrpl/protocol/MPTIssue.h>
28#include <xrpl/protocol/Protocol.h>
29#include <xrpl/protocol/SField.h>
30#include <xrpl/protocol/STAmount.h>
31#include <xrpl/protocol/SeqProxy.h>
32#include <xrpl/protocol/TER.h>
33#include <xrpl/protocol/TxFlags.h>
34#include <xrpl/protocol/UintTypes.h>
35#include <xrpl/protocol/jss.h>
55 for (
bool const withTokenEscrow : {
false,
true})
57 auto const amend = withTokenEscrow ? features : features - featureTokenEscrow;
58 Env env{*
this, amend};
59 auto const baseFee = env.
current()->fees().base;
60 auto const alice =
Account(
"alice");
61 auto const bob =
Account(
"bob");
62 auto const gw =
Account{
"gateway"};
63 auto const usd = gw[
"USD"];
64 env.
fund(
XRP(5000), alice, bob, gw);
65 env(
fset(gw, asfAllowTrustLineLocking));
67 env.
trust(usd(10'000), alice, bob);
69 env(
pay(gw, alice, usd(5000)));
70 env(
pay(gw, bob, usd(5000)));
76 auto const seq1 = env.
seq(alice);
90 auto const seq2 = env.
seq(alice);
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)));
120 auto const seq1 = env.
seq(alice);
141 Env env{*
this, features};
142 auto const baseFee = env.
current()->fees().base;
143 auto const alice =
Account(
"alice");
144 auto const bob =
Account(
"bob");
145 auto const gw =
Account{
"gateway"};
146 auto const usd = gw[
"USD"];
147 env.
fund(
XRP(5000), alice, bob, gw);
148 env(
fset(gw, asfAllowTrustLineLocking));
150 env.
trust(usd(10'000), alice, bob);
152 env(
pay(gw, alice, usd(5000)));
153 env(
pay(gw, bob, usd(5000)));
157 auto const seq1 = env.
seq(alice);
165 auto const seq2 = env.
seq(alice);
174 env(
fclear(gw, asfAllowTrustLineLocking));
208 Env env{*
this, features};
209 auto const alice =
Account(
"alice");
210 auto const bob =
Account(
"bob");
211 auto const gw =
Account{
"gateway"};
212 auto const usd = gw[
"USD"];
213 env.
fund(
XRP(5000), alice, bob, gw);
224 Env env{*
this, features};
225 auto const baseFee = env.
current()->fees().base;
226 auto const alice =
Account(
"alice");
227 auto const bob =
Account(
"bob");
228 auto const gw =
Account{
"gateway"};
229 auto const usd = gw[
"USD"];
230 env.
fund(
XRP(5000), alice, bob, gw);
242 Env env{*
this, features};
243 auto const baseFee = env.
current()->fees().base;
244 auto const alice =
Account(
"alice");
245 auto const bob =
Account(
"bob");
246 auto const gw =
Account{
"gateway"};
248 env.
fund(
XRP(5000), alice, bob, gw);
268 Env env{*
this, features};
269 auto const baseFee = env.
current()->fees().base;
270 auto const alice =
Account(
"alice");
271 auto const bob =
Account(
"bob");
272 auto const gw =
Account{
"gateway"};
273 auto const usd = gw[
"USD"];
274 env.
fund(
XRP(5000), alice, bob, gw);
286 Env env{*
this, features};
287 auto const baseFee = env.
current()->fees().base;
288 auto const alice =
Account(
"alice");
289 auto const bob =
Account(
"bob");
290 auto const gw =
Account{
"gateway"};
291 auto const usd = gw[
"USD"];
292 env.
fund(
XRP(5000), alice, bob);
306 Env env{*
this, features};
307 auto const baseFee = env.
current()->fees().base;
308 auto const alice =
Account(
"alice");
309 auto const bob =
Account(
"bob");
310 auto const gw =
Account{
"gateway"};
311 auto const usd = gw[
"USD"];
312 env.
fund(
XRP(5000), alice, bob, gw);
314 env.
trust(usd(10'000), alice, bob);
316 env(
pay(gw, alice, usd(5000)));
317 env(
pay(gw, bob, usd(5000)));
330 Env env{*
this, features};
331 auto const baseFee = env.
current()->fees().base;
332 auto const alice =
Account(
"alice");
333 auto const bob =
Account(
"bob");
334 auto const gw =
Account{
"gateway"};
335 auto const usd = gw[
"USD"];
336 env.
fund(
XRP(5000), alice, bob, gw);
337 env(
fset(gw, asfAllowTrustLineLocking));
351 Env env{*
this, features};
352 auto const baseFee = env.
current()->fees().base;
353 auto const alice =
Account(
"alice");
354 auto const bob =
Account(
"bob");
355 auto const gw =
Account{
"gateway"};
356 auto const usd = gw[
"USD"];
357 env.
fund(
XRP(5000), alice, bob, gw);
358 env(
fset(gw, asfAllowTrustLineLocking));
359 env(
fset(gw, asfRequireAuth));
361 env.
trust(usd(10'000), alice, bob);
374 Env env{*
this, features};
375 auto const baseFee = env.
current()->fees().base;
376 auto const alice =
Account(
"alice");
377 auto const bob =
Account(
"bob");
378 auto const gw =
Account{
"gateway"};
379 auto const usd = gw[
"USD"];
380 auto const aliceUSD = alice[
"USD"];
381 env.
fund(
XRP(5000), alice, bob, gw);
382 env(
fset(gw, asfAllowTrustLineLocking));
383 env(
fset(gw, asfRequireAuth));
386 env.
trust(usd(10'000), alice, bob);
400 Env env{*
this, features};
401 auto const alice =
Account(
"alice");
402 auto const bob =
Account(
"bob");
403 auto const gw =
Account{
"gateway"};
404 auto const usd = gw[
"USD"];
405 auto const baseFee = env.
current()->fees().base;
406 env.
fund(
XRP(10'000), alice, bob, gw);
407 env(
fset(gw, asfAllowTrustLineLocking));
409 env(
trust(alice, usd(100'000)));
410 env(
trust(bob, usd(100'000)));
412 env(
pay(gw, alice, usd(10'000)));
413 env(
pay(gw, bob, usd(10'000)));
417 env(
trust(gw, usd(10'000), alice, tfSetFreeze));
431 Env env{*
this, features};
432 auto const alice =
Account(
"alice");
433 auto const bob =
Account(
"bob");
434 auto const gw =
Account{
"gateway"};
435 auto const usd = gw[
"USD"];
436 auto const baseFee = env.
current()->fees().base;
437 env.
fund(
XRP(10'000), alice, bob, gw);
438 env(
fset(gw, asfAllowTrustLineLocking));
440 env(
trust(alice, usd(100'000)));
441 env(
trust(bob, usd(100'000)));
443 env(
pay(gw, alice, usd(10'000)));
444 env(
pay(gw, bob, usd(10'000)));
448 env(
trust(gw, usd(10'000), bob, tfSetFreeze));
462 Env env{*
this, features};
463 auto const alice =
Account(
"alice");
464 auto const bob =
Account(
"bob");
465 auto const gw =
Account{
"gateway"};
466 auto const usd = gw[
"USD"];
467 auto const baseFee = env.
current()->fees().base;
468 env.
fund(
XRP(10'000), alice, bob, gw);
469 env(
fset(gw, asfAllowTrustLineLocking));
471 env(
trust(alice, usd(100'000)));
472 env(
trust(bob, usd(100'000)));
486 Env env{*
this, features};
487 auto const alice =
Account(
"alice");
488 auto const bob =
Account(
"bob");
489 auto const gw =
Account{
"gateway"};
490 auto const usd = gw[
"USD"];
491 auto const baseFee = env.
current()->fees().base;
492 env.
fund(
XRP(10'000), alice, bob, gw);
493 env(
fset(gw, asfAllowTrustLineLocking));
495 env(
trust(alice, usd(100'000)));
496 env(
trust(bob, usd(100'000)));
498 env(
pay(gw, alice, usd(10'000)));
499 env(
pay(gw, bob, usd(10'000)));
512 Env env{*
this, features};
513 auto const alice =
Account(
"alice");
514 auto const bob =
Account(
"bob");
515 auto const gw =
Account{
"gateway"};
516 auto const usd = gw[
"USD"];
517 auto const baseFee = env.
current()->fees().base;
518 env.
fund(
XRP(10'000), alice, bob, gw);
519 env(
fset(gw, asfAllowTrustLineLocking));
521 env.
trust(usd(100000000000000000), alice);
522 env.
trust(usd(100000000000000000), bob);
524 env(
pay(gw, alice, usd(10000000000000000)));
525 env(
pay(gw, bob, usd(1)));
528 bool const largeMantissa = features[featureSingleAssetVault] ||
529 features[featureLendingProtocol] || features[featureMPTokensV2];
550 Env env{*
this, features};
551 auto const baseFee = env.
current()->fees().base;
552 auto const alice =
Account(
"alice");
553 auto const bob =
Account(
"bob");
554 auto const gw =
Account{
"gateway"};
555 auto const usd = gw[
"USD"];
556 auto const aliceUSD = alice[
"USD"];
557 auto const bobUSD = bob[
"USD"];
558 env.
fund(
XRP(5000), alice, bob, gw);
559 env(
fset(gw, asfAllowTrustLineLocking));
560 env(
fset(gw, asfRequireAuth));
564 env.
trust(usd(10'000), alice, bob);
566 env(
pay(gw, alice, usd(10'000)));
567 env(
pay(gw, bob, usd(10'000)));
570 auto const seq1 = env.
seq(alice);
578 env(
pay(bob, gw, usd(10'000)));
580 env(
trust(bob, usd(0)));
583 env.
trust(usd(10'000), bob);
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 env.
fund(
XRP(5000), alice, bob, gw);
604 env(
fset(gw, asfAllowTrustLineLocking));
606 env.
trust(usd(10'000), alice, bob);
608 env(
pay(gw, alice, usd(10'000)));
609 env(
pay(gw, bob, usd(10'000)));
612 auto const seq1 = env.
seq(alice);
621 env(
trust(gw, usd(10'000), bob, tfSetFreeze | tfSetDeepFreeze));
642 Env env{*
this, features};
643 auto const baseFee = env.
current()->fees().base;
644 auto const acctReserve = env.
current()->fees().reserve;
645 auto const incReserve = env.
current()->fees().increment;
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, gw);
651 env.
fund(acctReserve + (incReserve - 1), bob);
653 env(
fset(gw, asfAllowTrustLineLocking));
655 env.
trust(usd(10'000), alice);
657 env(
pay(gw, alice, usd(10'000)));
660 auto const seq1 = env.
seq(alice);
679 Env env{*
this, features};
680 auto const baseFee = env.
current()->fees().base;
681 auto const alice =
Account(
"alice");
682 auto const bob =
Account(
"bob");
683 auto const gw =
Account{
"gateway"};
684 auto const usd = gw[
"USD"];
685 env.
fund(
XRP(5000), alice, bob, gw);
687 env(
fset(gw, asfAllowTrustLineLocking));
689 env.
trust(usd(10'000), alice);
691 env(
pay(gw, alice, usd(10'000)));
694 auto const seq1 = env.
seq(alice);
713 Env env{*
this, features};
714 auto const baseFee = env.
current()->fees().base;
715 auto const alice =
Account(
"alice");
716 auto const bob =
Account(
"bob");
717 auto const gw =
Account{
"gateway"};
718 auto const usd = gw[
"USD"];
719 env.
fund(
XRP(5000), alice, bob, gw);
721 env(
fset(gw, asfAllowTrustLineLocking));
723 env.
trust(usd(1000), alice, bob);
725 env(
pay(gw, alice, usd(1000)));
728 auto const seq1 = env.
seq(alice);
736 env.
trust(usd(1), bob);
750 Env env{*
this, features};
751 auto const baseFee = env.
current()->fees().base;
752 auto const alice =
Account(
"alice");
753 auto const bob =
Account(
"bob");
754 auto const gw =
Account{
"gateway"};
755 auto const usd = gw[
"USD"];
756 env.
fund(
XRP(5000), alice, bob, gw);
758 env(
fset(gw, asfAllowTrustLineLocking));
760 env.
trust(usd(1000), alice, bob);
762 env(
pay(gw, alice, usd(1000)));
765 auto const seq1 = env.
seq(alice);
773 env.
trust(usd(1), bob);
777 auto const bobPreLimit = env.
limit(bob, usd);
787 BEAST_EXPECT(env.
limit(bob, usd) == bobPreLimit);
800 Env env{*
this, features};
801 auto const baseFee = env.
current()->fees().base;
802 auto const alice =
Account(
"alice");
803 auto const bob =
Account(
"bob");
804 auto const gw =
Account{
"gateway"};
805 auto const usd = gw[
"USD"];
806 auto const aliceUSD = alice[
"USD"];
807 auto const bobUSD = bob[
"USD"];
808 env.
fund(
XRP(5000), alice, bob, gw);
809 env(
fset(gw, asfAllowTrustLineLocking));
810 env(
fset(gw, asfRequireAuth));
814 env.
trust(usd(10'000), alice, bob);
816 env(
pay(gw, alice, usd(10'000)));
817 env(
pay(gw, bob, usd(10'000)));
820 auto const seq1 = env.
seq(alice);
828 env(
pay(alice, gw, usd(9'999)));
830 env(
trust(alice, usd(0)));
833 env.
trust(usd(10'000), alice);
850 Env env{*
this, features};
851 auto const baseFee = env.
current()->fees().base;
852 auto const alice =
Account(
"alice");
853 auto const bob =
Account(
"bob");
855 auto const usd = gw[
"USD"];
857 env.
fund(
XRP(10'000), alice, bob, gw);
860 env(
fset(gw, asfAllowTrustLineLocking));
863 env.
trust(usd(100'000), alice);
864 env.
trust(usd(100'000), bob);
867 env(
pay(gw, alice, usd(10'000)));
870 auto const seq = env.
seq(alice);
877 BEAST_EXPECT(env.
balance(alice, usd) == usd(9'000));
879 env(
pay(alice, gw, usd(9'000)));
882 env(
trust(alice, usd(0)));
886 BEAST_EXPECT(!env.
current()->exists(trustLineKey));
891 auto const expectedResult = env.
current()->rules().enabled(fixCleanup3_2_0)
897 if (env.
current()->rules().enabled(fixCleanup3_2_0))
900 BEAST_EXPECT(env.
current()->exists(trustLineKey));
901 BEAST_EXPECT(env.
balance(alice, usd) == usd(1'000));
909 testcase(
"IOU Cancel Reserve Recycle");
916 Env env{*
this, features};
917 bool const fixEnabled = env.
current()->rules().enabled(fixCleanup3_4_0);
919 auto const baseFee = env.
current()->fees().base;
920 auto const alice =
Account(
"alice");
921 auto const bob =
Account(
"bob");
923 auto const usd = gw[
"USD"];
925 env.
fund(
XRP(10'000), alice, bob, gw);
928 env(
fset(gw, asfAllowTrustLineLocking));
931 env.
trust(usd(10'000), alice);
934 env(
pay(gw, alice, usd(10'000)));
938 auto const cancelAfter = env.
now() + 100s;
939 auto const seq = env.
seq(alice);
948 env(
trust(alice, usd(0)));
950 BEAST_EXPECT(!env.
current()->exists(trustLineKey));
955 auto const oneObject = env.
current()->fees().accountReserve(1, 1);
956 auto const twoObjects = env.
current()->fees().accountReserve(2, 1);
958 auto const feeCushion = baseFee.
drops() * 20;
959 env(
pay(alice, bob,
drops(balance.drops() - oneObject.drops() - feeCushion)));
964 for (; env.
now() < cancelAfter; env.
close())
977 BEAST_EXPECT(!env.
le(escrowKey));
978 BEAST_EXPECT(env.
current()->exists(trustLineKey));
979 BEAST_EXPECT(env.
balance(alice, usd) == usd(10'000));
986 BEAST_EXPECT(env.
le(escrowKey) !=
nullptr);
987 BEAST_EXPECT(!env.
current()->exists(trustLineKey));
990 env(
pay(bob, alice,
drops(twoObjects.drops() - oneObject.drops())));
994 BEAST_EXPECT(!env.
le(escrowKey));
995 BEAST_EXPECT(env.
balance(alice, usd) == usd(10'000));
1004 using namespace jtx;
1007 Env env{*
this, features};
1008 auto const baseFee = env.
current()->fees().base;
1009 auto const alice =
Account(
"alice");
1010 auto const bob =
Account(
"bob");
1011 auto const gw =
Account{
"gateway"};
1012 auto const usd = gw[
"USD"];
1013 env.
fund(
XRP(5000), alice, bob, gw);
1014 env(
fset(gw, asfAllowTrustLineLocking));
1016 env.
trust(usd(10'000), alice, bob);
1018 env(
pay(gw, alice, usd(5'000)));
1019 env(
pay(gw, bob, usd(5'000)));
1022 auto const outstandingUSD = usd(10'000);
1025 auto const seq1 = env.
seq(alice);
1027 auto const preAliceUSD = env.
balance(alice, usd);
1028 auto const preBobUSD = env.
balance(bob, usd);
1036 BEAST_EXPECT(env.
balance(alice, usd) == preAliceUSD - usd(1'000));
1037 BEAST_EXPECT(env.
balance(bob, usd) == preBobUSD);
1038 BEAST_EXPECT(
issuerBalance(env, gw, usd) == outstandingUSD - usd(1'000));
1042 auto const preAliceUSD = env.
balance(alice, usd);
1043 auto const preBobUSD = env.
balance(bob, usd);
1051 BEAST_EXPECT(env.
balance(alice, usd) == preAliceUSD);
1052 BEAST_EXPECT(env.
balance(bob, usd) == preBobUSD + usd(1'000));
1053 BEAST_EXPECT(
issuerBalance(env, gw, usd) == outstandingUSD);
1058 auto const seq2 = env.
seq(alice);
1060 auto const preAliceUSD = env.
balance(alice, usd);
1061 auto const preBobUSD = env.
balance(bob, usd);
1070 BEAST_EXPECT(env.
balance(alice, usd) == preAliceUSD - usd(1'000));
1071 BEAST_EXPECT(env.
balance(bob, usd) == preBobUSD);
1072 BEAST_EXPECT(
issuerBalance(env, gw, usd) == outstandingUSD - usd(1'000));
1076 auto const preAliceUSD = env.
balance(alice, usd);
1077 auto const preBobUSD = env.
balance(bob, usd);
1081 BEAST_EXPECT(env.
balance(alice, usd) == preAliceUSD + usd(1'000));
1082 BEAST_EXPECT(env.
balance(bob, usd) == preBobUSD);
1083 BEAST_EXPECT(
issuerBalance(env, gw, usd) == outstandingUSD);
1091 using namespace jtx;
1094 auto const alice =
Account(
"alice");
1095 auto const bob =
Account(
"bob");
1096 auto const carol =
Account(
"carol");
1097 auto const gw =
Account{
"gateway"};
1098 auto const usd = gw[
"USD"];
1102 Env env{*
this, features};
1103 env.
fund(
XRP(5000), alice, bob, carol, gw);
1104 env(
fset(gw, asfAllowTrustLineLocking));
1106 env.
trust(usd(10'000), alice, bob, carol);
1108 env(
pay(gw, alice, usd(5000)));
1109 env(
pay(gw, bob, usd(5000)));
1110 env(
pay(gw, carol, usd(5000)));
1112 auto const aseq = env.
seq(alice);
1113 auto const bseq = env.
seq(bob);
1128 std::find(aod.begin(), aod.end(), aa) != aod.end());
1136 std::find(iod.begin(), iod.end(), aa) != iod.end());
1153 std::find(bod.begin(), bod.end(), bb) != bod.end());
1161 std::find(iod.begin(), iod.end(), bb) != iod.end());
1175 std::find(aod.begin(), aod.end(), aa) == aod.end());
1181 std::find(bod.begin(), bod.end(), bb) != bod.end());
1187 std::find(iod.begin(), iod.end(), bb) != iod.end());
1201 std::find(bod.begin(), bod.end(), bb) == bod.end());
1207 std::find(iod.begin(), iod.end(), bb) == iod.end());
1213 Env env{*
this, features};
1214 env.
fund(
XRP(5000), alice, bob, carol, gw);
1215 env(
fset(gw, asfAllowTrustLineLocking));
1217 env.
trust(usd(10'000), alice, bob, carol);
1219 env(
pay(gw, alice, usd(5000)));
1220 env(
pay(gw, bob, usd(5000)));
1221 env(
pay(gw, carol, usd(5000)));
1223 auto const aseq = env.
seq(alice);
1224 auto const bseq = env.
seq(bob);
1248 std::find(aod.begin(), aod.end(), ab) != aod.end());
1254 std::find(bod.begin(), bod.end(), ab) != bod.end());
1257 std::find(bod.begin(), bod.end(), bc) != bod.end());
1263 std::find(cod.begin(), cod.end(), bc) != cod.end());
1269 std::find(iod.begin(), iod.end(), ab) != iod.end());
1272 std::find(iod.begin(), iod.end(), bc) != iod.end());
1285 std::find(aod.begin(), aod.end(), ab) == aod.end());
1291 std::find(bod.begin(), bod.end(), ab) == bod.end());
1294 std::find(bod.begin(), bod.end(), bc) != bod.end());
1303 std::find(iod.begin(), iod.end(), ab) == iod.end());
1306 std::find(iod.begin(), iod.end(), bc) != iod.end());
1319 std::find(aod.begin(), aod.end(), ab) == aod.end());
1325 std::find(bod.begin(), bod.end(), ab) == bod.end());
1328 std::find(bod.begin(), bod.end(), bc) == bod.end());
1337 std::find(iod.begin(), iod.end(), ab) == iod.end());
1340 std::find(iod.begin(), iod.end(), bc) == iod.end());
1345 testcase(
"IOU Metadata to issuer");
1347 Env env{*
this, features};
1348 env.
fund(
XRP(5000), alice, carol, gw);
1349 env(
fset(gw, asfAllowTrustLineLocking));
1351 env.
trust(usd(10'000), alice, carol);
1353 env(
pay(gw, alice, usd(5000)));
1354 env(
pay(gw, carol, usd(5000)));
1356 auto const aseq = env.
seq(alice);
1377 std::find(aod.begin(), aod.end(), ag) != aod.end());
1386 std::find(iod.begin(), iod.end(), ag) != iod.end());
1398 std::find(aod.begin(), aod.end(), ag) == aod.end());
1407 std::find(iod.begin(), iod.end(), ag) == iod.end());
1419 struct TestAccountData
1435 .hasTrustline =
false,
1443 .hasTrustline =
false,
1451 .hasTrustline =
false,
1459 .hasTrustline =
false,
1467 .hasTrustline =
true,
1475 .hasTrustline =
true,
1483 .hasTrustline =
true,
1491 .hasTrustline =
true,
1497 for (
auto const& t :
tests)
1499 Env env{*
this, features};
1500 auto const baseFee = env.
current()->fees().base;
1501 auto const usd = t.gw[
"USD"];
1502 env.
fund(
XRP(5000), t.src, t.dst, t.gw);
1503 env(
fset(t.gw, asfAllowTrustLineLocking));
1508 env.
trust(usd(100'000), t.src, t.dst);
1512 env.
trust(usd(100'000), t.src);
1516 env(
pay(t.gw, t.src, usd(10'000)));
1518 env(
pay(t.gw, t.dst, usd(10'000)));
1522 auto const seq1 = env.
seq(t.src);
1523 auto const delta = usd(1'000);
1527 Fee(baseFee * 150));
1531 auto const preSrc = env.
balance(t.src, usd);
1532 auto const preDst = env.
balance(t.dst, usd);
1537 Fee(baseFee * 150));
1540 BEAST_EXPECT(env.
balance(t.src, usd) == preSrc);
1541 BEAST_EXPECT(env.
balance(t.dst, usd) == preDst + delta);
1552 struct TestAccountData
1561 auto const gw =
Account{
"gateway"};
1562 auto const alice =
Account{
"alice"};
1563 Env env{*
this, features};
1564 auto const baseFee = env.
current()->fees().base;
1565 auto const usd = gw[
"USD"];
1566 env.
fund(
XRP(5000), alice, gw);
1567 env(
fset(gw, asfAllowTrustLineLocking));
1569 env.
trust(usd(100'000), alice);
1572 env(
pay(gw, alice, usd(10'000)));
1587 {.src =
Account(
"alice2"), .dst =
Account{
"gw0"}, .hasTrustline =
true},
1589 {.src =
Account(
"carol0"), .dst =
Account{
"gw1"}, .hasTrustline =
true},
1591 {.src =
Account(
"dan1"), .dst =
Account{
"gw0"}, .hasTrustline =
true},
1593 {.src =
Account(
"bob0"), .dst =
Account{
"gw1"}, .hasTrustline =
true},
1598 for (
auto const& t : gwDstTests)
1600 Env env{*
this, features};
1601 auto const baseFee = env.
current()->fees().base;
1602 auto const usd = t.dst[
"USD"];
1603 env.
fund(
XRP(5000), t.dst, t.src);
1604 env(
fset(t.dst, asfAllowTrustLineLocking));
1607 env.
trust(usd(100'000), t.src);
1610 env(
pay(t.dst, t.src, usd(10'000)));
1614 auto const seq1 = env.
seq(t.src);
1615 auto const preSrc = env.
balance(t.src, usd);
1619 Fee(baseFee * 150));
1626 Fee(baseFee * 150));
1628 auto const preAmount = 10'000;
1629 BEAST_EXPECT(preSrc == usd(preAmount));
1630 auto const postAmount = 9000;
1631 BEAST_EXPECT(env.
balance(t.src, usd) == usd(postAmount));
1632 BEAST_EXPECT(env.
balance(t.dst, usd) == usd(0));
1637 auto const gw =
Account{
"gateway"};
1638 auto const usd = gw[
"USD"];
1639 Env env{*
this, features};
1640 auto const baseFee = env.
current()->fees().base;
1642 env(
fset(gw, asfAllowTrustLineLocking));
1662 auto const alice =
Account(
"alice");
1663 auto const bob =
Account(
"bob");
1664 auto const carol =
Account(
"carol");
1665 auto const gw =
Account{
"gateway"};
1666 auto const usd = gw[
"USD"];
1670 Env env{*
this, features};
1671 auto const baseFee = env.
current()->fees().base;
1672 env.
fund(
XRP(10'000), alice, bob, gw);
1673 env(
fset(gw, asfAllowTrustLineLocking));
1674 env(
rate(gw, 1.25));
1676 env.
trust(usd(100'000), alice);
1677 env.
trust(usd(100'000), bob);
1679 env(
pay(gw, alice, usd(10'000)));
1680 env(
pay(gw, bob, usd(10'000)));
1684 auto const preAlice = env.
balance(alice, usd);
1685 auto const seq1 = env.
seq(alice);
1686 auto const delta = usd(125);
1690 Fee(baseFee * 150));
1699 Fee(baseFee * 150));
1702 BEAST_EXPECT(env.
balance(alice, usd) == preAlice - delta);
1703 BEAST_EXPECT(env.
balance(bob, usd) == usd(10'100));
1707 Env env{*
this, features};
1708 auto const baseFee = env.
current()->fees().base;
1709 env.
fund(
XRP(10'000), alice, bob, gw);
1710 env(
fset(gw, asfAllowTrustLineLocking));
1711 env(
rate(gw, 1.25));
1713 env.
trust(usd(100'000), alice);
1714 env.
trust(usd(100'000), bob);
1716 env(
pay(gw, alice, usd(10'000)));
1717 env(
pay(gw, bob, usd(10'000)));
1721 auto const preAlice = env.
balance(alice, usd);
1722 auto const seq1 = env.
seq(alice);
1723 auto const delta = usd(125);
1727 Fee(baseFee * 150));
1733 env(
rate(gw, 1.26));
1740 Fee(baseFee * 150));
1743 BEAST_EXPECT(env.
balance(alice, usd) == preAlice - delta);
1744 BEAST_EXPECT(env.
balance(bob, usd) == usd(10'100));
1749 Env env{*
this, features};
1750 auto const baseFee = env.
current()->fees().base;
1751 env.
fund(
XRP(10'000), alice, bob, gw);
1752 env(
fset(gw, asfAllowTrustLineLocking));
1753 env(
rate(gw, 1.25));
1755 env.
trust(usd(100'000), alice);
1756 env.
trust(usd(100'000), bob);
1758 env(
pay(gw, alice, usd(10'000)));
1759 env(
pay(gw, bob, usd(10'000)));
1763 auto const preAlice = env.
balance(alice, usd);
1764 auto const seq1 = env.
seq(alice);
1765 auto const delta = usd(125);
1769 Fee(baseFee * 150));
1775 env(
rate(gw, 1.00));
1782 Fee(baseFee * 150));
1785 BEAST_EXPECT(env.
balance(alice, usd) == preAlice - delta);
1786 BEAST_EXPECT(env.
balance(bob, usd) == usd(10125));
1791 Env env{*
this, features};
1792 auto const baseFee = env.
current()->fees().base;
1793 env.
fund(
XRP(10'000), alice, bob, gw);
1794 env(
fset(gw, asfAllowTrustLineLocking));
1795 env(
rate(gw, 1.25));
1797 env.
trust(usd(100'000), alice);
1798 env.
trust(usd(100'000), bob);
1800 env(
pay(gw, alice, usd(10'000)));
1801 env(
pay(gw, bob, usd(10'000)));
1805 auto const preAlice = env.
balance(alice, usd);
1806 auto const seq1 = env.
seq(alice);
1807 auto const delta = usd(125);
1817 env(
rate(gw, 1.00));
1824 BEAST_EXPECT(env.
balance(alice, usd) == preAlice);
1825 BEAST_EXPECT(env.
balance(bob, usd) == usd(10000));
1836 auto const alice =
Account(
"alice");
1837 auto const bob =
Account(
"bob");
1838 auto const gw =
Account{
"gateway"};
1839 auto const usd = gw[
"USD"];
1843 Env env{*
this, features};
1844 auto const baseFee = env.
current()->fees().base;
1845 env.
fund(
XRP(1'000), alice, bob, gw);
1846 env(
fset(gw, asfAllowTrustLineLocking));
1848 env.
trust(usd(10'000), alice, bob);
1850 env(
pay(gw, alice, usd(1'000)));
1851 env(
pay(gw, bob, usd(1'000)));
1855 auto seq1 = env.
seq(alice);
1856 auto const delta = usd(125);
1860 Fee(baseFee * 150));
1864 auto const preBobLimit = env.
limit(bob, usd);
1868 Fee(baseFee * 150));
1870 auto const postBobLimit = env.
limit(bob, usd);
1872 BEAST_EXPECT(postBobLimit == preBobLimit);
1883 auto const alice =
Account(
"alice");
1884 auto const bob =
Account(
"bob");
1885 auto const carol =
Account(
"carol");
1886 auto const gw =
Account{
"gateway"};
1887 auto const usd = gw[
"USD"];
1889 auto const aliceUSD = alice[
"USD"];
1890 auto const bobUSD = bob[
"USD"];
1892 Env env{*
this, features};
1893 auto const baseFee = env.
current()->fees().base;
1894 env.
fund(
XRP(1'000), alice, bob, gw);
1895 env(
fset(gw, asfAllowTrustLineLocking));
1896 env(
fset(gw, asfRequireAuth));
1899 env(
trust(alice, usd(10'000)));
1900 env(
trust(bob, usd(10'000)));
1902 env(
pay(gw, alice, usd(1'000)));
1906 auto seq1 = env.
seq(alice);
1907 auto const delta = usd(125);
1917 env(
trust(bob, usd(10'000)));
1919 env(
pay(gw, bob, usd(1'000)));
1923 seq1 = env.
seq(alice);
1927 Fee(baseFee * 150));
1934 Fee(baseFee * 150));
1945 auto const alice =
Account(
"alice");
1946 auto const bob =
Account(
"bob");
1947 auto const carol =
Account(
"carol");
1948 auto const gw =
Account{
"gateway"};
1949 auto const usd = gw[
"USD"];
1953 Env env{*
this, features};
1954 auto const baseFee = env.
current()->fees().base;
1955 env.
fund(
XRP(10'000), alice, bob, gw);
1956 env(
fset(gw, asfAllowTrustLineLocking));
1958 env.
trust(usd(100'000), alice);
1959 env.
trust(usd(100'000), bob);
1961 env(
pay(gw, alice, usd(10'000)));
1962 env(
pay(gw, bob, usd(10'000)));
1964 env(
fset(gw, asfGlobalFreeze));
1968 auto seq1 = env.
seq(alice);
1969 auto const delta = usd(125);
1980 env(
fclear(gw, asfGlobalFreeze));
1984 seq1 = env.
seq(alice);
1988 Fee(baseFee * 150));
1992 env(
fset(gw, asfGlobalFreeze));
1999 Fee(baseFee * 150));
2003 env(
fclear(gw, asfGlobalFreeze));
2007 seq1 = env.
seq(alice);
2011 Fee(baseFee * 150));
2015 env(
fset(gw, asfGlobalFreeze));
2026 Env env{*
this, features};
2027 auto const baseFee = env.
current()->fees().base;
2028 env.
fund(
XRP(10'000), alice, bob, gw);
2029 env(
fset(gw, asfAllowTrustLineLocking));
2031 env(
trust(alice, usd(100'000)));
2032 env(
trust(bob, usd(100'000)));
2034 env(
pay(gw, alice, usd(10'000)));
2035 env(
pay(gw, bob, usd(10'000)));
2039 env(
trust(gw, usd(10'000), alice, tfSetFreeze));
2043 auto seq1 = env.
seq(alice);
2044 auto const delta = usd(125);
2055 env(
trust(gw, usd(10'000), alice, tfClearFreeze));
2059 seq1 = env.
seq(alice);
2063 Fee(baseFee * 150));
2067 env(
trust(gw, usd(10'000), bob, tfSetFreeze));
2074 Fee(baseFee * 150));
2078 env(
trust(gw, usd(10'000), alice, tfClearFreeze));
2079 env(
trust(gw, usd(10'000), bob, tfClearFreeze));
2083 seq1 = env.
seq(alice);
2087 Fee(baseFee * 150));
2091 env(
trust(gw, usd(10'000), bob, tfSetFreeze));
2102 Env env{*
this, features};
2103 auto const baseFee = env.
current()->fees().base;
2104 env.
fund(
XRP(10'000), alice, bob, gw);
2105 env(
fset(gw, asfAllowTrustLineLocking));
2107 env(
trust(alice, usd(100'000)));
2108 env(
trust(bob, usd(100'000)));
2110 env(
pay(gw, alice, usd(10'000)));
2111 env(
pay(gw, bob, usd(10'000)));
2115 env(
trust(gw, usd(10'000), alice, tfSetFreeze | tfSetDeepFreeze));
2119 auto seq1 = env.
seq(alice);
2120 auto const delta = usd(125);
2131 env(
trust(gw, usd(10'000), alice, tfClearFreeze | tfClearDeepFreeze));
2135 seq1 = env.
seq(alice);
2139 Fee(baseFee * 150));
2143 env(
trust(gw, usd(10'000), bob, tfSetFreeze | tfSetDeepFreeze));
2155 env(
trust(gw, usd(10'000), alice, tfClearFreeze | tfClearDeepFreeze));
2156 env(
trust(gw, usd(10'000), bob, tfClearFreeze | tfClearDeepFreeze));
2160 seq1 = env.
seq(alice);
2164 Fee(baseFee * 150));
2168 env(
trust(gw, usd(10'000), bob, tfSetFreeze | tfSetDeepFreeze));
2179 testcase(
"IOU Insufficient Funds");
2183 auto const alice =
Account(
"alice");
2184 auto const bob =
Account(
"bob");
2185 auto const carol =
Account(
"carol");
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(100'000), alice);
2197 env.
trust(usd(100'000), bob);
2199 env(
pay(gw, alice, usd(10'000)));
2200 env(
pay(gw, bob, usd(10'000)));
2204 auto const delta = usd(1'000);
2208 Fee(baseFee * 150));
2215 Env env{*
this, features};
2216 auto const baseFee = env.
current()->fees().base;
2217 env.
fund(
XRP(10'000), alice, bob, gw);
2218 env(
fset(gw, asfAllowTrustLineLocking));
2220 env.
trust(usd(100'000), alice);
2221 env.
trust(usd(100'000), bob);
2223 env(
pay(gw, alice, usd(10'000)));
2224 env(
pay(gw, bob, usd(10'000)));
2227 auto const delta = usd(1'000);
2231 Fee(baseFee * 150));
2250 auto const alice =
Account(
"alice");
2251 auto const bob =
Account(
"bob");
2252 auto const gw =
Account{
"gateway"};
2253 auto const usd = gw[
"USD"];
2257 Env env(*
this, features);
2258 auto const baseFee = env.
current()->fees().base;
2259 env.
fund(
XRP(10'000), alice, bob, gw);
2260 env(
fset(gw, asfAllowTrustLineLocking));
2262 env.
trust(usd(100000000000000000), alice);
2263 env.
trust(usd(100000000000000000), bob);
2265 env(
pay(gw, alice, usd(10000000000000000)));
2266 env(
pay(gw, bob, usd(1)));
2269 bool const largeMantissa = features[featureSingleAssetVault] ||
2270 features[featureLendingProtocol] || features[featureMPTokensV2];
2280 auto const seq1 = env.
seq(alice);
2285 Fee(baseFee * 150));
2292 Fee(baseFee * 150));
2302 using namespace jtx;
2305 for (
bool const withTokenEscrow : {
false,
true})
2307 auto const amend = withTokenEscrow ? features : features - featureTokenEscrow;
2308 Env env{*
this, amend};
2309 auto const baseFee = env.
current()->fees().base;
2310 auto const alice =
Account(
"alice");
2311 auto const bob =
Account(
"bob");
2312 auto const gw =
Account(
"gw");
2315 MPTTester mptGw(env, gw, {.holders = {alice}});
2317 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2318 mptGw.authorize({.account = alice});
2319 auto const mpt = mptGw[
"MPT"];
2320 env(
pay(gw, alice, mpt(10'000)));
2326 auto const seq1 = env.
seq(alice);
2339 auto const seq2 = env.
seq(alice);
2359 for (
bool const withMPT : {
true,
false})
2361 auto const amend = withMPT ? features : features - featureMPTokensV1;
2362 Env env{*
this, amend};
2363 auto const baseFee = env.
current()->fees().base;
2364 auto const alice =
Account(
"alice");
2365 auto const bob =
Account(
"bob");
2366 auto const gw =
Account(
"gw");
2367 env.
fund(
XRP(1'000), alice, bob, gw);
2371 jv[jss::Amount][jss::mpt_issuance_id] =
2372 "00000004A407AF5856CCF3C42619DAA925813FC955C72983";
2373 jv[jss::Amount][jss::value] =
"-1";
2386 Env env{*
this, features};
2387 auto const baseFee = env.
current()->fees().base;
2388 auto const alice =
Account(
"alice");
2389 auto const bob =
Account(
"bob");
2390 auto const gw =
Account(
"gw");
2392 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2394 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2395 mptGw.authorize({.account = alice});
2396 mptGw.authorize({.account = bob});
2397 auto const mpt = mptGw[
"MPT"];
2398 env(
pay(gw, alice, mpt(10'000)));
2399 env(
pay(gw, bob, mpt(10'000)));
2420 Env env{*
this, features};
2421 auto const baseFee = env.
current()->fees().base;
2422 auto const alice =
Account(
"alice");
2423 auto const gw =
Account(
"gw");
2425 MPTTester mptGw(env, gw, {.holders = {alice}});
2427 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2428 mptGw.authorize({.account = alice});
2429 auto const mpt = mptGw[
"MPT"];
2430 env(
pay(gw, alice, mpt(10'000)));
2443 Env env{*
this, features};
2444 auto const baseFee = env.
current()->fees().base;
2445 auto const alice =
Account(
"alice");
2446 auto const bob =
Account(
"bob");
2447 auto const gw =
Account(
"gw");
2448 env.
fund(
XRP(10'000), alice, bob, gw);
2453 jv[jss::Amount][jss::mpt_issuance_id] =
2454 "00000004A407AF5856CCF3C42619DAA925813FC955C72983";
2465 Env env{*
this, features};
2466 auto const baseFee = env.
current()->fees().base;
2467 auto const alice =
Account(
"alice");
2468 auto const bob =
Account(
"bob");
2469 auto const gw =
Account(
"gw");
2471 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2472 mptGw.
create({.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanTransfer});
2473 mptGw.authorize({.account = alice});
2474 mptGw.authorize({.account = bob});
2475 auto const mpt = mptGw[
"MPT"];
2476 env(
pay(gw, alice, mpt(10'000)));
2477 env(
pay(gw, bob, mpt(10'000)));
2490 Env env{*
this, features};
2491 auto const baseFee = env.
current()->fees().base;
2492 auto const alice =
Account(
"alice");
2493 auto const bob =
Account(
"bob");
2494 auto const gw =
Account(
"gw");
2496 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2498 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2499 auto const mpt = mptGw[
"MPT"];
2511 Env env{*
this, features};
2512 auto const baseFee = env.
current()->fees().base;
2513 auto const alice =
Account(
"alice");
2514 auto const bob =
Account(
"bob");
2515 auto const gw =
Account(
"gw");
2517 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2521 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTRequireAuth,
2523 mptGw.authorize({.account = alice});
2524 mptGw.authorize({.account = gw, .holder = alice});
2525 auto const mpt = mptGw[
"MPT"];
2526 env(
pay(gw, alice, mpt(10'000)));
2530 mptGw.authorize({.account = gw, .holder = alice, .flags = tfMPTUnauthorize});
2542 Env env{*
this, features};
2543 auto const baseFee = env.
current()->fees().base;
2544 auto const alice =
Account(
"alice");
2545 auto const bob =
Account(
"bob");
2546 auto const gw =
Account(
"gw");
2548 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2552 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTRequireAuth,
2554 mptGw.authorize({.account = alice});
2555 mptGw.authorize({.account = gw, .holder = alice});
2556 mptGw.authorize({.account = bob});
2557 mptGw.authorize({.account = gw, .holder = bob});
2558 auto const mpt = mptGw[
"MPT"];
2559 env(
pay(gw, alice, mpt(10'000)));
2560 env(
pay(gw, bob, mpt(10'000)));
2564 mptGw.authorize({.account = gw, .holder = bob, .flags = tfMPTUnauthorize});
2576 Env env{*
this, features};
2577 auto const baseFee = env.
current()->fees().base;
2578 auto const alice =
Account(
"alice");
2579 auto const bob =
Account(
"bob");
2580 auto const gw =
Account(
"gw");
2582 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2586 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTCanLock,
2588 mptGw.authorize({.account = alice});
2589 mptGw.authorize({.account = bob});
2590 auto const mpt = mptGw[
"MPT"];
2591 env(
pay(gw, alice, mpt(10'000)));
2592 env(
pay(gw, bob, mpt(10'000)));
2596 mptGw.set({.account = gw, .holder = alice, .flags = tfMPTLock});
2608 Env env{*
this, features};
2609 auto const baseFee = env.
current()->fees().base;
2610 auto const alice =
Account(
"alice");
2611 auto const bob =
Account(
"bob");
2612 auto const gw =
Account(
"gw");
2614 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2618 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTCanLock,
2620 mptGw.authorize({.account = alice});
2621 mptGw.authorize({.account = bob});
2622 auto const mpt = mptGw[
"MPT"];
2623 env(
pay(gw, alice, mpt(10'000)));
2624 env(
pay(gw, bob, mpt(10'000)));
2628 mptGw.set({.account = gw, .holder = bob, .flags = tfMPTLock});
2640 Env env{*
this, features};
2641 auto const baseFee = env.
current()->fees().base;
2642 auto const alice =
Account(
"alice");
2643 auto const bob =
Account(
"bob");
2644 auto const gw =
Account(
"gw");
2646 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2647 mptGw.
create({.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow});
2648 mptGw.authorize({.account = alice});
2649 mptGw.authorize({.account = bob});
2650 auto const mpt = mptGw[
"MPT"];
2651 env(
pay(gw, alice, mpt(10'000)));
2652 env(
pay(gw, bob, mpt(10'000)));
2665 Env env{*
this, features};
2666 auto const baseFee = env.
current()->fees().base;
2667 auto const alice =
Account(
"alice");
2668 auto const bob =
Account(
"bob");
2669 auto const gw =
Account(
"gw");
2671 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2673 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2674 mptGw.authorize({.account = alice});
2675 mptGw.authorize({.account = bob});
2676 auto const mpt = mptGw[
"MPT"];
2677 env(
pay(gw, bob, mpt(10)));
2690 Env env{*
this, features};
2691 auto const baseFee = env.
current()->fees().base;
2692 auto const alice =
Account(
"alice");
2693 auto const bob =
Account(
"bob");
2694 auto const gw =
Account(
"gw");
2696 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2698 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2699 mptGw.authorize({.account = alice});
2700 mptGw.authorize({.account = bob});
2701 auto const mpt = mptGw[
"MPT"];
2702 env(
pay(gw, alice, mpt(10)));
2703 env(
pay(gw, bob, mpt(10)));
2724 Env env{*
this, features};
2725 auto const baseFee = env.
current()->fees().base;
2726 auto const alice =
Account(
"alice");
2727 auto const bob =
Account(
"bob");
2728 auto const gw =
Account(
"gw");
2730 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2734 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTRequireAuth,
2736 mptGw.authorize({.account = alice});
2737 mptGw.authorize({.account = gw, .holder = alice});
2738 mptGw.authorize({.account = bob});
2739 mptGw.authorize({.account = gw, .holder = bob});
2740 auto const mpt = mptGw[
"MPT"];
2741 env(
pay(gw, alice, mpt(10'000)));
2742 env(
pay(gw, bob, mpt(10'000)));
2745 auto const seq1 = env.
seq(alice);
2754 mptGw.authorize({.account = gw, .holder = bob, .flags = tfMPTUnauthorize});
2766 Env env{*
this, features};
2767 auto const baseFee = env.
current()->fees().base;
2768 auto const alice =
Account(
"alice");
2769 auto const bob =
Account(
"bob");
2770 env.
fund(
XRP(10'000), alice, bob);
2773 auto const seq1 = env.
seq(alice);
2780 sleNew->setAccountID(sfDestination, bob);
2781 sleNew->setFieldAmount(sfAmount, amt);
2797 Env env{*
this, features};
2798 auto const baseFee = env.
current()->fees().base;
2799 auto const alice =
Account(
"alice");
2800 auto const bob =
Account(
"bob");
2801 auto const gw =
Account(
"gw");
2803 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2807 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTCanLock,
2809 mptGw.authorize({.account = alice});
2810 mptGw.authorize({.account = bob});
2811 auto const mpt = mptGw[
"MPT"];
2812 env(
pay(gw, alice, mpt(10'000)));
2813 env(
pay(gw, bob, mpt(10'000)));
2816 auto const seq1 = env.
seq(alice);
2825 mptGw.set({.account = gw, .holder = bob, .flags = tfMPTLock});
2845 Env env{*
this, features};
2846 auto const baseFee = env.
current()->fees().base;
2847 auto const acctReserve = env.
current()->fees().reserve;
2848 auto const incReserve = env.
current()->fees().increment;
2850 auto const alice =
Account(
"alice");
2851 auto const bob =
Account(
"bob");
2852 auto const gw =
Account(
"gw");
2853 env.
fund(acctReserve + (incReserve - 1), bob);
2856 MPTTester mptGw(env, gw, {.holders = {alice}});
2858 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2859 mptGw.authorize({.account = alice});
2860 auto const mpt = mptGw[
"MPT"];
2861 env(
pay(gw, alice, mpt(10'000)));
2864 auto const seq1 = env.
seq(alice);
2882 Env env{*
this, features};
2883 auto const baseFee = env.
current()->fees().base;
2884 auto const alice =
Account(
"alice");
2885 auto const bob =
Account(
"bob");
2886 auto const gw =
Account(
"gw");
2890 MPTTester mptGw(env, gw, {.holders = {alice}});
2892 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2893 mptGw.authorize({.account = alice});
2894 auto const mpt = mptGw[
"MPT"];
2895 env(
pay(gw, alice, mpt(10'000)));
2898 auto const seq1 = env.
seq(alice);
2916 Env env{*
this, features};
2917 auto const baseFee = env.
current()->fees().base;
2918 auto const alice =
Account(
"alice");
2919 auto const bob =
Account(
"bob");
2920 auto const carol =
Account(
"carol");
2921 auto const gw =
Account(
"gw");
2922 env.
fund(
XRP(10'000), bob, carol);
2925 MPTTester mptGw(env, gw, {.holders = {alice}});
2927 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
2928 mptGw.authorize({.account = alice});
2929 auto const mpt = mptGw[
"MPT"];
2930 env(
pay(gw, alice, mpt(10'000)));
2933 auto const seq1 = env.
seq(alice);
2959 Env env{*
this, features};
2960 auto const baseFee = env.
current()->fees().base;
2961 auto const alice =
Account(
"alice");
2962 auto const bob =
Account(
"bob");
2963 auto const gw =
Account(
"gw");
2965 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
2969 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTRequireAuth,
2971 mptGw.authorize({.account = alice});
2972 mptGw.authorize({.account = gw, .holder = alice});
2973 mptGw.authorize({.account = bob});
2974 mptGw.authorize({.account = gw, .holder = bob});
2975 auto const mpt = mptGw[
"MPT"];
2976 env(
pay(gw, alice, mpt(10'000)));
2977 env(
pay(gw, bob, mpt(10'000)));
2980 auto const seq1 = env.
seq(alice);
2989 mptGw.authorize({.account = gw, .holder = alice, .flags = tfMPTUnauthorize});
2997 Env env{*
this, features};
2998 auto const baseFee = env.
current()->fees().base;
2999 auto const alice =
Account(
"alice");
3000 auto const bob =
Account(
"bob");
3001 env.
fund(
XRP(10'000), alice, bob);
3003 auto const seq1 = env.
seq(alice);
3010 sleNew->setAccountID(sfDestination, bob);
3011 sleNew->setFieldAmount(sfAmount, amt);
3027 using namespace jtx;
3030 Env env{*
this, features};
3031 auto const baseFee = env.
current()->fees().base;
3032 auto const alice =
Account(
"alice");
3033 auto const bob =
Account(
"bob");
3034 auto const carol =
Account(
"carol");
3035 auto const gw =
Account(
"gw");
3038 MPTTester mptGw(env, gw, {.holders = {alice, carol}});
3040 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
3041 mptGw.authorize({.account = alice});
3042 mptGw.authorize({.account = carol});
3043 auto const mpt = mptGw[
"MPT"];
3044 env(
pay(gw, alice, mpt(10'000)));
3045 env(
pay(gw, carol, mpt(10'000)));
3048 auto const outstandingMPT = env.
balance(gw, mpt);
3051 auto const seq1 = env.
seq(alice);
3053 auto const preAliceMPT = env.
balance(alice, mpt);
3054 auto const preBobMPT = env.
balance(bob, mpt);
3062 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1'000));
3063 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == 1'000);
3064 BEAST_EXPECT(env.
balance(bob, mpt) == preBobMPT);
3066 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3070 auto const preAliceMPT = env.
balance(alice, mpt);
3071 auto const preBobMPT = env.
balance(bob, mpt);
3079 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT);
3081 BEAST_EXPECT(env.
balance(bob, mpt) == preBobMPT + mpt(1'000));
3083 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3088 auto const seq2 = env.
seq(alice);
3090 auto const preAliceMPT = env.
balance(alice, mpt);
3091 auto const preBobMPT = env.
balance(bob, mpt);
3100 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1'000));
3101 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == 1'000);
3102 BEAST_EXPECT(env.
balance(bob, mpt) == preBobMPT);
3104 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3108 auto const preAliceMPT = env.
balance(alice, mpt);
3109 auto const preBobMPT = env.
balance(bob, mpt);
3113 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT + mpt(1'000));
3115 BEAST_EXPECT(env.
balance(bob, mpt) == preBobMPT);
3117 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3123 auto const seq = env.
seq(alice);
3124 auto const preAliceMPT = env.
balance(alice, mpt);
3132 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1'000));
3133 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == 1'000);
3134 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3144 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT);
3146 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3152 auto const seq = env.
seq(alice);
3153 auto const preAliceMPT = env.
balance(alice, mpt);
3162 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1'000));
3163 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == 1'000);
3164 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3170 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT);
3172 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3178 auto const preAliceMPT = env.
balance(alice, mpt);
3179 auto const preBobMPT = env.
balance(bob, mpt);
3180 auto const preCarolMPT = env.
balance(carol, mpt);
3195 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1'000));
3196 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == 1'000);
3197 BEAST_EXPECT(env.
balance(bob, mpt) == preBobMPT);
3199 BEAST_EXPECT(env.
balance(carol, mpt) == preCarolMPT - mpt(1'000));
3200 BEAST_EXPECT(
mptEscrowed(env, carol, mpt) == 1'000);
3201 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3207 Env env{*
this, features};
3208 auto const baseFee = env.
current()->fees().base;
3209 auto const alice =
Account(
"alice");
3210 auto const bob =
Account(
"bob");
3211 auto const gw =
Account(
"gw");
3213 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
3215 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
3216 mptGw.authorize({.account = alice});
3217 mptGw.authorize({.account = bob});
3218 auto const mpt = mptGw[
"MPT"];
3222 auto const preAliceMPT = env.
balance(alice, mpt);
3223 auto const preBobMPT = env.
balance(bob, mpt);
3224 auto const outstandingMPT = env.
balance(gw, mpt);
3226 auto const seq1 = env.
seq(alice);
3230 Fee(baseFee * 150));
3233 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1));
3235 BEAST_EXPECT(env.
balance(bob, mpt) == preBobMPT);
3237 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3247 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1));
3251 BEAST_EXPECT(env.
balance(bob, mpt) == preBobMPT + mpt(1));
3253 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3261 Env env{*
this, features};
3262 auto const baseFee = env.
current()->fees().base;
3263 auto const alice =
Account(
"alice");
3264 auto const bob =
Account(
"bob");
3265 auto const gw =
Account(
"gw");
3267 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
3269 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
3270 mptGw.authorize({.account = alice});
3271 mptGw.authorize({.account = bob});
3272 auto const mpt = mptGw[
"MPT"];
3276 auto const preAliceMPT = env.
balance(alice, mpt);
3277 auto const preBobMPT = env.
balance(bob, mpt);
3278 auto const outstandingMPT = env.
balance(gw, mpt);
3281 auto const seq1 = env.
seq(alice);
3285 Fee(baseFee * 150));
3289 auto const seq2 = env.
seq(alice);
3293 Fee(baseFee * 150));
3298 BEAST_EXPECT(env.
balance(bob, mpt) == preBobMPT);
3300 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3321 BEAST_EXPECT(env.
balance(gw, mpt) == outstandingMPT);
3329 using namespace jtx;
3332 auto const alice =
Account(
"alice");
3333 auto const bob =
Account(
"bob");
3334 auto const carol =
Account(
"carol");
3335 auto const gw =
Account{
"gateway"};
3339 Env env{*
this, features};
3340 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
3342 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
3343 mptGw.authorize({.account = alice});
3344 mptGw.authorize({.account = bob});
3345 auto const mpt = mptGw[
"MPT"];
3346 env(
pay(gw, alice, mpt(10'000)));
3347 env(
pay(gw, bob, mpt(10'000)));
3349 auto const aseq = env.
seq(alice);
3350 auto const bseq = env.
seq(bob);
3365 std::find(aod.begin(), aod.end(), aa) != aod.end());
3373 std::find(iod.begin(), iod.end(), aa) == iod.end());
3390 std::find(bod.begin(), bod.end(), bb) != bod.end());
3404 std::find(aod.begin(), aod.end(), aa) == aod.end());
3410 std::find(bod.begin(), bod.end(), bb) != bod.end());
3424 std::find(bod.begin(), bod.end(), bb) == bod.end());
3431 Env env{*
this, features};
3432 MPTTester mptGw(env, gw, {.holders = {alice, bob, carol}});
3434 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
3435 mptGw.authorize({.account = alice});
3436 mptGw.authorize({.account = bob});
3437 mptGw.authorize({.account = carol});
3438 auto const mpt = mptGw[
"MPT"];
3439 env(
pay(gw, alice, mpt(10'000)));
3440 env(
pay(gw, bob, mpt(10'000)));
3441 env(
pay(gw, carol, mpt(10'000)));
3443 auto const aseq = env.
seq(alice);
3444 auto const bseq = env.
seq(bob);
3468 std::find(aod.begin(), aod.end(), ab) != aod.end());
3474 std::find(bod.begin(), bod.end(), ab) != bod.end());
3477 std::find(bod.begin(), bod.end(), bc) != bod.end());
3483 std::find(cod.begin(), cod.end(), bc) != cod.end());
3496 std::find(aod.begin(), aod.end(), ab) == aod.end());
3502 std::find(bod.begin(), bod.end(), ab) == bod.end());
3505 std::find(bod.begin(), bod.end(), bc) != bod.end());
3521 std::find(aod.begin(), aod.end(), ab) == aod.end());
3527 std::find(bod.begin(), bod.end(), ab) == bod.end());
3530 std::find(bod.begin(), bod.end(), bc) == bod.end());
3547 Env env{*
this, features};
3548 auto const baseFee = env.
current()->fees().base;
3549 auto const alice =
Account(
"alice");
3550 auto const gw =
Account(
"gw");
3552 MPTTester mptGw(env, gw, {.holders = {alice}});
3554 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
3555 mptGw.authorize({.account = alice});
3556 auto const mpt = mptGw[
"MPT"];
3557 env(
pay(gw, alice, mpt(10'000)));
3561 auto const seq1 = env.
seq(alice);
3562 auto const preAliceMPT = env.
balance(alice, mpt);
3563 auto const preOutstanding = env.
balance(gw, mpt);
3565 BEAST_EXPECT(preOutstanding == mpt(-10'000));
3566 BEAST_EXPECT(preEscrowed == 0);
3571 Fee(baseFee * 150));
3574 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1'000));
3575 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == 1'000);
3576 BEAST_EXPECT(env.
balance(gw, mpt) == preOutstanding);
3583 Fee(baseFee * 150));
3586 BEAST_EXPECT(env.
balance(alice, mpt) == preAliceMPT - mpt(1'000));
3588 BEAST_EXPECT(env.
balance(gw, mpt) == preOutstanding + mpt(1'000));
3600 auto const alice =
Account(
"alice");
3601 auto const bob =
Account(
"bob");
3602 auto const carol =
Account(
"carol");
3603 auto const gw =
Account{
"gateway"};
3604 auto const usd = gw[
"USD"];
3608 Env env{*
this, features};
3609 auto const baseFee = env.
current()->fees().base;
3610 auto const alice =
Account(
"alice");
3611 auto const bob =
Account(
"bob");
3612 auto const gw =
Account(
"gw");
3614 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
3616 .transferFee = 25000,
3619 .flags = tfMPTCanEscrow | tfMPTCanTransfer,
3621 mptGw.authorize({.account = alice});
3622 mptGw.authorize({.account = bob});
3623 auto const mpt = mptGw[
"MPT"];
3624 env(
pay(gw, alice, mpt(10'000)));
3625 env(
pay(gw, bob, mpt(10'000)));
3629 auto const preAlice = env.
balance(alice, mpt);
3630 auto const seq1 = env.
seq(alice);
3631 auto const delta = mpt(125);
3635 Fee(baseFee * 150));
3640 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == 125);
3642 BEAST_EXPECT(env.
balance(gw, mpt) == mpt(-20'000));
3648 Fee(baseFee * 150));
3651 BEAST_EXPECT(env.
balance(alice, mpt) == preAlice - delta);
3652 BEAST_EXPECT(env.
balance(bob, mpt) == mpt(10'100));
3654 auto const escrowedWithFix = env.
current()->rules().enabled(fixTokenEscrowV1) ? 0 : 25;
3655 auto const outstandingWithFix =
3656 env.
current()->rules().enabled(fixTokenEscrowV1) ? mpt(19'975) : mpt(20'000);
3657 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == escrowedWithFix);
3659 BEAST_EXPECT(env.
balance(gw, mpt) == -outstandingWithFix);
3664 Env env{*
this, features};
3665 auto const baseFee = env.
current()->fees().base;
3666 auto const alice =
Account(
"alice");
3667 auto const bob =
Account(
"bob");
3668 auto const gw =
Account(
"gw");
3670 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
3672 .transferFee = 25000,
3675 .flags = tfMPTCanEscrow | tfMPTCanTransfer,
3677 mptGw.authorize({.account = alice});
3678 mptGw.authorize({.account = bob});
3679 auto const mpt = mptGw[
"MPT"];
3680 env(
pay(gw, alice, mpt(10'000)));
3681 env(
pay(gw, bob, mpt(10'000)));
3685 auto const preAlice = env.
balance(alice, mpt);
3686 auto const preBob = env.
balance(bob, mpt);
3687 auto const seq1 = env.
seq(alice);
3688 auto const delta = mpt(125);
3693 Fee(baseFee * 150));
3702 BEAST_EXPECT(env.
balance(alice, mpt) == preAlice);
3703 BEAST_EXPECT(env.
balance(bob, mpt) == preBob);
3704 BEAST_EXPECT(env.
balance(gw, mpt) == mpt(-20'000));
3711 Env env{*
this, features};
3712 auto const baseFee = env.
current()->fees().base;
3713 auto const alice =
Account(
"alice");
3714 auto const bob =
Account(
"bob");
3715 auto const gw =
Account(
"gw");
3717 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
3719 .transferFee = 25000,
3722 .flags = tfMPTCanEscrow | tfMPTCanTransfer,
3724 mptGw.authorize({.account = alice});
3725 mptGw.authorize({.account = bob});
3726 auto const mpt = mptGw[
"MPT"];
3727 env(
pay(gw, alice, mpt(10'000)));
3728 env(
pay(gw, bob, mpt(10'000)));
3732 auto const preAlice = env.
balance(alice, mpt);
3733 auto const seq1 = env.
seq(alice);
3734 auto const delta = mpt(125);
3738 Fee(baseFee * 150));
3743 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == 125);
3745 BEAST_EXPECT(env.
balance(gw, mpt) == mpt(-20'000));
3751 Fee(baseFee * 150));
3754 BEAST_EXPECT(env.
balance(alice, mpt) == preAlice - delta);
3757 BEAST_EXPECT(env.
balance(gw, mpt) == mpt(-19'875));
3767 bool const withCleanup340 = features[fixCleanup3_4_0];
3770 (withCleanup340 ?
"with Cleanup340" :
"without Cleanup340"));
3772 Env env{*
this, features};
3773 auto const baseFee = env.
current()->fees().base;
3774 auto const alice =
Account(
"alice");
3775 auto const bob =
Account(
"bob");
3776 auto const gw =
Account(
"gw");
3777 env.
fund(
XRP(1'000), alice, bob, gw);
3783 .holders = {alice, bob},
3784 .transferFee = 1'000,
3785 .flags = tfMPTCanEscrow | tfMPTCanTransfer,
3787 env(
pay(gw, alice, mpt(10'000)));
3790 static constexpr int escrowCount = 10;
3791 static constexpr int splitAmount = 10;
3792 static constexpr int totalLocked = escrowCount * splitAmount;
3794 for (
auto& seq : seqs)
3796 seq = env.
seq(alice);
3800 Fee(baseFee * 150));
3804 BEAST_EXPECT(env.
balance(alice, mpt) == mpt(10'000 - totalLocked));
3805 BEAST_EXPECT(env.
balance(bob, mpt) == mpt(0));
3806 BEAST_EXPECT(env.
balance(gw, mpt) == mpt(-10'000));
3807 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == totalLocked);
3810 for (
auto const seq : seqs)
3815 Fee(baseFee * 150));
3819 auto const feeBurned = withCleanup340 ? escrowCount : 0;
3820 BEAST_EXPECT(env.
balance(alice, mpt) == mpt(10'000 - totalLocked));
3821 BEAST_EXPECT(env.
balance(bob, mpt) == mpt(totalLocked - feeBurned));
3822 BEAST_EXPECT(env.
balance(gw, mpt) == mpt(-10'000 + feeBurned));
3834 auto constexpr escrowAmount = 200'000'000'000'000'000LL;
3835 auto constexpr noOverflowEscrowAmount = 186'000'000'000'000'000LL;
3836 auto const alice =
Account(
"alice");
3837 auto const bob =
Account(
"bob");
3838 auto const gw =
Account(
"gw");
3840 for (
auto const testFeatures : {
3841 features - featureMPTokensV2 - fixCleanup3_4_0 - fixCleanup3_5_0,
3842 features - featureMPTokensV2 - fixCleanup3_4_0,
3843 features - featureMPTokensV2 - fixCleanup3_5_0,
3844 features - featureMPTokensV2,
3845 (features | featureMPTokensV2) - fixCleanup3_4_0 - fixCleanup3_5_0,
3846 (features | featureMPTokensV2) - fixCleanup3_4_0,
3847 (features | featureMPTokensV2) - fixCleanup3_5_0,
3848 features | featureMPTokensV2,
3849 features | fixCleanup3_5_0,
3852 bool const mptV2 = testFeatures[featureMPTokensV2];
3853 bool const tokenEscrowV1 = testFeatures[fixTokenEscrowV1];
3861 bool const cleanup340 = testFeatures[fixCleanup3_4_0];
3862 bool const noOverflow = cleanup340 || mptV2 || testFeatures[fixCleanup3_5_0];
3870 Env env{*
this, testFeatures};
3871 env.
fund(
XRP(1'000), alice, bob, gw);
3872 auto const baseFee = env.
current()->fees().base;
3877 .holders = {alice, bob},
3878 .transferFee = 1'000,
3879 .flags = tfMPTCanEscrow | tfMPTCanTransfer,
3881 env(
pay(gw, alice, mpt(escrowAmount)));
3884 auto const preAlice = env.
balance(alice, mpt);
3885 auto const preBob = env.
balance(bob, mpt);
3886 auto const seq = env.
seq(alice);
3891 Fee(baseFee * 150));
3894 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == escrowAmount);
3907 BEAST_EXPECT(env.
balance(alice, mpt) == preAlice - mpt(escrowAmount));
3908 auto const postBob = env.
balance(bob, mpt);
3909 BEAST_EXPECT(postBob.value() > preBob.value());
3910 BEAST_EXPECT(postBob.value() < (preBob + mpt(escrowAmount)).value());
3911 auto const xferFee = escrowAmount - (postBob.value() - preBob.value());
3912 auto const expectedEscrow = tokenEscrowV1 ? 0 : xferFee;
3913 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == expectedEscrow);
3919 BEAST_EXPECT(env.
balance(alice, mpt) == preAlice - mpt(escrowAmount));
3920 BEAST_EXPECT(env.
balance(bob, mpt) == preBob);
3921 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == escrowAmount);
3929 Env env{*
this, testFeatures};
3930 env.
fund(
XRP(1'000), alice, bob, gw);
3931 auto const baseFee = env.
current()->fees().base;
3936 .holders = {alice, bob},
3937 .transferFee = 1'000,
3938 .flags = tfMPTCanEscrow | tfMPTCanTransfer,
3940 env(
pay(gw, alice, mpt(noOverflowEscrowAmount)));
3943 auto const preAlice = env.
balance(alice, mpt);
3944 auto const preBob = env.
balance(bob, mpt);
3945 auto const seq = env.
seq(alice);
3950 Fee(baseFee * 150));
3953 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == noOverflowEscrowAmount);
3964 BEAST_EXPECT(env.
balance(alice, mpt) == preAlice - mpt(noOverflowEscrowAmount));
3965 auto const postBob = env.
balance(bob, mpt);
3966 BEAST_EXPECT(postBob.value() > preBob.value());
3967 BEAST_EXPECT(postBob.value() < (preBob + mpt(noOverflowEscrowAmount)).value());
3968 auto const xferFee = noOverflowEscrowAmount - (postBob.value() - preBob.value());
3969 auto const expectedEscrow = tokenEscrowV1 ? 0 : xferFee;
3970 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == expectedEscrow);
3977 Env env{*
this, testFeatures};
3978 env.
fund(
XRP(1'000), alice, bob, gw);
3979 auto const baseFee = env.
current()->fees().base;
3984 .holders = {alice, bob},
3985 .transferFee = 1'000,
3986 .flags = tfMPTCanEscrow | tfMPTCanTransfer,
3988 env(
pay(gw, alice, mpt(escrowAmount)));
3991 auto const preAlice = env.
balance(alice, mpt);
3992 auto const preBob = env.
balance(bob, mpt);
3993 auto const seq = env.
seq(alice);
3998 Fee(baseFee * 150));
4001 BEAST_EXPECT(
mptEscrowed(env, alice, mpt) == escrowAmount);
4008 BEAST_EXPECT(env.
balance(alice, mpt) == preAlice);
4009 BEAST_EXPECT(env.
balance(bob, mpt) == preBob);
4010 BEAST_EXPECT(env.
balance(gw, mpt) == -mpt(escrowAmount));
4024 Env env{*
this, features};
4025 auto const baseFee = env.
current()->fees().base;
4026 auto const alice =
Account(
"alice");
4027 auto const bob =
Account(
"bob");
4028 auto const gw =
Account(
"gw");
4030 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
4034 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTRequireAuth,
4036 mptGw.authorize({.account = alice});
4037 mptGw.authorize({.account = gw, .holder = alice});
4038 mptGw.authorize({.account = bob});
4039 mptGw.authorize({.account = gw, .holder = bob});
4040 auto const mpt = mptGw[
"MPT"];
4041 env(
pay(gw, alice, mpt(10'000)));
4044 auto seq = env.
seq(alice);
4045 auto const delta = mpt(125);
4050 Fee(baseFee * 150));
4057 Fee(baseFee * 150));
4068 Env env{*
this, features};
4069 auto const baseFee = env.
current()->fees().base;
4070 auto const alice =
Account(
"alice");
4071 auto const bob =
Account(
"bob");
4072 auto const gw =
Account(
"gw");
4074 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
4078 .flags = tfMPTCanEscrow | tfMPTCanTransfer | tfMPTCanLock,
4080 mptGw.authorize({.account = alice});
4081 mptGw.authorize({.account = bob});
4082 auto const mpt = mptGw[
"MPT"];
4083 env(
pay(gw, alice, mpt(10'000)));
4084 env(
pay(gw, bob, mpt(10'000)));
4088 auto seq1 = env.
seq(alice);
4093 Fee(baseFee * 150));
4097 mptGw.set({.account = gw, .holder = alice, .flags = tfMPTLock});
4098 mptGw.set({.account = gw, .holder = bob, .flags = tfMPTLock});
4120 Env env{*
this, features};
4121 auto const baseFee = env.
current()->fees().base;
4122 auto const alice =
Account(
"alice");
4123 auto const bob =
Account(
"bob");
4124 auto const gw =
Account(
"gw");
4126 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
4127 mptGw.
create({.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow});
4128 mptGw.authorize({.account = alice});
4129 mptGw.authorize({.account = bob});
4130 auto const mpt = mptGw[
"MPT"];
4131 env(
pay(gw, alice, mpt(10'000)));
4132 env(
pay(gw, bob, mpt(10'000)));
4147 auto seq = env.
seq(alice);
4151 Fee(baseFee * 150));
4158 Fee(baseFee * 150));
4165 auto seq = env.
seq(alice);
4170 Fee(baseFee * 150));
4188 Env env{*
this, features};
4189 auto const baseFee = env.
current()->fees().base;
4190 auto const alice =
Account(
"alice");
4191 auto const bob =
Account(
"bob");
4192 auto const gw =
Account(
"gw");
4194 MPTTester mptGw(env, gw, {.holders = {alice, bob}});
4196 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
4197 mptGw.authorize({.account = alice});
4198 mptGw.authorize({.account = bob});
4199 auto const mpt = mptGw[
"MPT"];
4200 env(
pay(gw, alice, mpt(10'000)));
4201 env(
pay(gw, bob, mpt(10'000)));
4204 auto const seq1 = env.
seq(alice);
4208 Fee(baseFee * 150));
4212 env(
pay(alice, gw, mpt(9'990)));
4213 env(
pay(bob, gw, mpt(10'000)));
4214 BEAST_EXPECT(env.
balance(alice, mpt) == mpt(0));
4216 BEAST_EXPECT(env.
balance(bob, mpt) == mpt(0));
4218 BEAST_EXPECT(env.
balance(gw, mpt) == mpt(-10));
4219 mptGw.authorize({.account = bob, .flags = tfMPTUnauthorize});
4220 mptGw.destroy({.id = mptGw.issuanceID(), .ownerCount = 1, .err =
tecHAS_OBLIGATIONS});
4229 env(
pay(bob, gw, mpt(10)));
4230 mptGw.destroy({.id = mptGw.issuanceID(), .ownerCount = 0});
4235 Env env{*
this, features};
4236 auto const baseFee = env.
current()->fees().base;
4237 auto const alice =
Account(
"alice");
4238 auto const bob =
Account(
"bob");
4239 auto const gw =
Account(
"gw");
4243 MPTTester mptGw(env, gw, {.holders = {alice}});
4245 {.ownerCount = 1, .holderCount = 0, .flags = tfMPTCanEscrow | tfMPTCanTransfer});
4246 mptGw.authorize({.account = alice});
4247 auto const mpt = mptGw[
"MPT"];
4248 env(
pay(gw, alice, mpt(10'000)));
4251 auto const seq1 = env.
seq(alice);
4259 env(
pay(alice, gw, mpt(9'990)));
4262 BEAST_EXPECT(env.
balance(alice, mpt) == mpt(0));
4274 BEAST_EXPECT(env.
balance(alice, mpt) == mpt(0));
4276 mptGw.authorize({.account = alice, .flags = tfMPTUnauthorize});
4331 {all - featureSingleAssetVault - featureLendingProtocol - featureMPTokensV2, 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.
bool modify(ModifyType const &f)
Modify the open ledger.
Writable ledger view that accumulates state and tx changes.
Discardable, editable view to a ledger.
static constexpr SeqProxy rawSequence(std::uint32_t v)
Factory function to return a sequence-based SeqProxy.
virtual OpenLedger & getOpenLedger()=0
constexpr value_type drops() const
Returns the number of drops.
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.
std::uint32_t ownerCount(Account const &account) const
Return the number of objects owned by an account.
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.
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{}, std::source_location const &loc=std::source_location::current())
Converts to MPT Issue or STAmount.
Match clear account flags.
Set the expected result code for a JTx The test will fail if the code doesn't match.
Keylet escrow(AccountID const &src, SeqProxy const &seq) noexcept
An escrow entry.
Keylet mptoken(MPTID const &issuanceID, AccountID const &holder) noexcept
Keylet mptokenIssuance(MPTID const &issuanceID) 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.
auto const kFinishTime
Set the "FinishAfter" time tag on a JTx.
std::array< std::uint8_t, 39 > const kCb2
Rate rate(Env const &env, Account const &account, std::uint32_t const &seq)
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.
jtx::PrettyAmount issuerBalance(jtx::Env &env, jtx::Account const &account, Issue const &issue)
json::Value fclear(Account const &account, std::uint32_t off)
Remove account flag.
FeatureBitset testableAmendments()
uint64_t issuerMPTEscrowed(jtx::Env const &env, jtx::MPT const &mpt)
std::vector< SLE::const_pointer > ownerDirEntries(ReadView const &view, AccountID const &account)
Return the ledger entries in an account's owner directory.
json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
json::Value rate(Account const &account, double multiplier)
Set a transfer rate.
uint64_t mptEscrowed(jtx::Env const &env, jtx::Account const &account, jtx::MPT const &mpt)
jtx::PrettyAmount issuerEscrowed(jtx::Env &env, jtx::Account const &account, Issue const &issue)
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.
Rate transferRate(ReadView const &view, AccountID const &issuer)
Returns IOU issuer transfer fee as Rate.
MPTID makeMptID(std::uint32_t const sequence, AccountID const &account)
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.
void testMPTLargeLockedRate(FeatureBitset features)
void testMPTCreatePreclaim(FeatureBitset features)
void testMPTFinishDoApply(FeatureBitset features)
void testMPTMetaAndOwnership(FeatureBitset features)
void testIOUBalances(FeatureBitset features)
void testMPTSplitEscrowTransferFee(FeatureBitset features)
void testIOUCreatePreclaim(FeatureBitset features)
void testMPTGateway(FeatureBitset features)
void testMPTCanTransfer(FeatureBitset features)
void testIOUFinishPreclaim(FeatureBitset features)
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)
void testMPTRequireAuth(FeatureBitset features)
void testIOUFinishDoApply(FeatureBitset features)
void testIOUFreeze(FeatureBitset features)
void testMPTEnablement(FeatureBitset features)
void testIOUCancelPreclaim(FeatureBitset features)
void testIOUGateway(FeatureBitset features)
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 testIOUCancelReserveRecycle(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)
STAmount const & value() const