1#include <test/jtx/Account.h>
2#include <test/jtx/Env.h>
3#include <test/jtx/SignerUtils.h>
4#include <test/jtx/TestHelpers.h>
5#include <test/jtx/acctdelete.h>
6#include <test/jtx/amount.h>
7#include <test/jtx/balance.h>
8#include <test/jtx/batch.h>
9#include <test/jtx/check.h>
10#include <test/jtx/delegate.h>
11#include <test/jtx/envconfig.h>
12#include <test/jtx/fee.h>
13#include <test/jtx/flags.h>
14#include <test/jtx/mpt.h>
15#include <test/jtx/multisign.h>
16#include <test/jtx/noop.h>
17#include <test/jtx/offer.h>
18#include <test/jtx/pay.h>
19#include <test/jtx/regkey.h>
20#include <test/jtx/seq.h>
21#include <test/jtx/sig.h>
22#include <test/jtx/tags.h>
23#include <test/jtx/ter.h>
24#include <test/jtx/ticket.h>
25#include <test/jtx/trust.h>
26#include <test/jtx/txflags.h>
27#include <test/jtx/utility.h>
28#include <test/jtx/vault.h>
30#include <xrpld/app/ledger/LedgerMaster.h>
31#include <xrpld/app/ledger/OpenLedger.h>
32#include <xrpld/app/misc/Transaction.h>
33#include <xrpld/app/misc/TxQ.h>
35#include <xrpl/basics/base_uint.h>
36#include <xrpl/basics/strHex.h>
37#include <xrpl/beast/unit_test/suite.h>
38#include <xrpl/beast/utility/Journal.h>
39#include <xrpl/config/BasicConfig.h>
40#include <xrpl/config/Constants.h>
41#include <xrpl/core/HashRouter.h>
42#include <xrpl/json/json_value.h>
43#include <xrpl/json/to_string.h>
44#include <xrpl/ledger/ApplyView.h>
45#include <xrpl/ledger/OpenView.h>
46#include <xrpl/protocol/AccountID.h>
47#include <xrpl/protocol/Batch.h>
48#include <xrpl/protocol/ErrorCodes.h>
49#include <xrpl/protocol/Feature.h>
50#include <xrpl/protocol/Indexes.h>
51#include <xrpl/protocol/Issue.h>
52#include <xrpl/protocol/KeyType.h>
53#include <xrpl/protocol/MPTIssue.h>
54#include <xrpl/protocol/Protocol.h>
55#include <xrpl/protocol/SField.h>
56#include <xrpl/protocol/STParsedJSON.h>
57#include <xrpl/protocol/STTx.h>
58#include <xrpl/protocol/SecretKey.h>
59#include <xrpl/protocol/SeqProxy.h>
60#include <xrpl/protocol/Serializer.h>
61#include <xrpl/protocol/Sign.h>
62#include <xrpl/protocol/TER.h>
63#include <xrpl/protocol/TxFlags.h>
64#include <xrpl/protocol/TxFormats.h>
65#include <xrpl/protocol/Units.h>
66#include <xrpl/protocol/XRPAmount.h>
67#include <xrpl/protocol/jss.h>
68#include <xrpl/server/NetworkOPs.h>
69#include <xrpl/tx/Transactor.h>
70#include <xrpl/tx/apply.h>
71#include <xrpl/tx/transactors/payment/Payment.h>
72#include <xrpl/tx/transactors/system/Batch.h>
107 for (
auto const& txn : jrr[jss::result][jss::ledger][jss::transactions])
109 if (txn[jss::metaData][sfTransactionIndex.jsonName] == index)
119 params[jss::ledger_index] = env.
closed()->seq();
120 params[jss::transactions] =
true;
121 params[jss::expand] =
true;
129 auto const transactions = jrr[jss::result][jss::ledger][jss::transactions];
134 BEAST_EXPECT(txn[jss::hash].asString() == ledgerResult.txHash);
135 BEAST_EXPECT(txn.isMember(jss::metaData));
137 BEAST_EXPECT(txn[sfTransactionType.jsonName] == ledgerResult.txType);
138 BEAST_EXPECT(meta[sfTransactionResult.jsonName] == ledgerResult.result);
139 if (ledgerResult.batchID)
143 *ledgerResult.batchID,
146 ledgerResult.result);
151 template <
typename... Args>
158 auto const ids = batchTxn.stx->getBatchTransactionIDs();
161 for (
auto const&
id : ids)
163 TxID const batchID = batchTxn.stx->getTransactionID();
187 for (
auto const& [k, v] : extraTxQ)
198 auto const& view = *env.
current();
209 for (
bool const withBatch : {
true,
false})
211 testcase <<
"enabled: Batch " << (withBatch ?
"enabled" :
"disabled");
213 auto const amend = withBatch ? features : features - featureBatchV1_1;
215 Env env{*
this, amend};
217 auto const alice =
Account(
"alice");
218 auto const bob =
Account(
"bob");
219 auto const carol =
Account(
"carol");
220 env.
fund(
XRP(10000), alice, bob, carol);
225 auto const seq = env.
seq(alice);
258 Env env{*
this, features};
260 auto const alice =
Account(
"alice");
261 auto const bob =
Account(
"bob");
262 auto const carol =
Account(
"carol");
263 env.
fund(
XRP(10000), alice, bob, carol);
275 auto const seq = env.
seq(alice);
283 auto const seq = env.
seq(alice);
291 auto const seq = env.
seq(alice);
294 Txflags(tfAllOrNothing | tfOnlyOne),
301 auto const seq = env.
seq(alice);
309 auto const seq = env.
seq(alice);
320 auto const seq = env.
seq(alice);
339 auto const seq = env.
seq(alice);
352 auto const seq = env.
seq(alice);
365 auto const seq = env.
seq(alice);
379 auto const seq = env.
seq(alice);
381 auto const jt = env.
jt(
pay(alice, bob,
XRP(1)));
391 auto const seq = env.
seq(alice);
393 auto tx1 =
pay(alice, bob,
XRP(1));
396 tx1[sfSigners.jsonName][0U][sfSigner.jsonName][sfAccount.jsonName] = alice.human();
397 tx1[sfSigners.jsonName][0U][sfSigner.jsonName][sfSigningPubKey.jsonName] =
399 tx1[sfSigners.jsonName][0U][sfSigner.jsonName][sfTxnSignature.jsonName] =
"DEADBEEF";
410 auto const seq = env.
seq(alice);
413 tx1[jss::SigningPubKey] =
strHex(alice.pk());
425 auto const seq = env.
seq(alice);
446 Env disabledEnv{*
this, features - featureBatchV1_1};
447 disabledEnv.
fund(
XRP(10000), alice, bob);
453 disabledEnv.
current()->rules(),
472 auto const seq = env.
seq(alice);
485 auto const seq = env.
seq(alice);
488 tx1[jss::Fee] =
"-1";
498 auto const seq = env.
seq(alice);
501 tx1[jss::Fee] =
"1.5";
508 fail(
"Expected parse_error for fractional fee");
519 auto const seq = env.
seq(alice);
522 tx1[jss::Sequence] = seq + 1;
533 auto const seq = env.
seq(alice);
544 auto const seq = env.
seq(alice);
555 auto const seq = env.
seq(alice);
566 auto const seq = env.
seq(alice);
579 auto const seq = env.
seq(alice);
591 auto const seq = env.
seq(alice);
603 auto const seq = env.
seq(alice);
616 auto const seq = env.
seq(alice);
628 auto const seq = env.
seq(alice);
640 auto const seq = env.
seq(alice);
641 auto const bobSeq = env.
seq(bob);
651 jt.stx->getAccountID(sfAccount),
652 jt.stx->getSeqProxy().value(),
654 jt.stx->getBatchTransactionIDs());
657 jt.jv[sfBatchSigners.jsonName][0u][sfBatchSigner.jsonName][sfAccount.jsonName] =
659 jt.jv[sfBatchSigners.jsonName][0u][sfBatchSigner.jsonName][sfSigningPubKey.jsonName] =
661 jt.jv[sfBatchSigners.jsonName][0u][sfBatchSigner.jsonName][sfTxnSignature.jsonName] =
670 auto const seq = env.
seq(alice);
693 Env env{*
this, features};
695 auto const alice =
Account(
"alice");
696 auto const bob =
Account(
"bob");
697 auto const carol =
Account(
"carol");
698 auto const dave =
Account(
"dave");
699 auto const elsa =
Account(
"elsa");
700 auto const frank =
Account(
"frank");
701 auto const phantom =
Account(
"phantom");
704 env.
fund(
XRP(10000), alice, bob, carol, dave, elsa, frank);
712 auto const seq = env.
seq(alice);
727 auto const seq = env.
seq(alice);
737 env(
signers(alice, 2, {{bob, 1}, {carol, 1}}));
740 env(
signers(bob, 2, {{carol, 1}, {dave, 1}, {elsa, 1}}));
745 auto const seq = env.
seq(alice);
757 auto const seq = env.
seq(alice);
762 batch::Msig(bob, {carol, Account(
"dave", KeyType::Ed25519)}),
770 env(
fset(elsa, asfDisableMaster),
Sig(elsa));
771 auto const seq = env.
seq(alice);
783 auto const seq = env.
seq(alice);
795 auto const seq = env.
seq(alice);
809 auto const seq = env.seq(alice);
813 batch::Inner(
pay(alice, bob,
XRP(10)), seq + 1),
814 batch::Inner(
pay(bob, alice,
XRP(5)), env.seq(bob)),
815 batch::Msig(bob, {carol, Reg{dave, davo}}),
822 auto const seq = env.seq(alice);
825 batch::Inner(
pay(alice, bob,
XRP(10)), seq + 1),
826 batch::Inner(
pay(bob, alice,
XRP(5)), env.seq(bob)),
827 batch::Msig(bob, {carol}),
834 auto const seq = env.seq(alice);
837 batch::Inner(
pay(alice, bob,
XRP(10)), seq + 1),
838 batch::Inner(
pay(bob, alice,
XRP(5)), env.seq(bob)),
839 batch::Msig(bob, {carol, dave}),
846 auto const seq = env.seq(alice);
849 batch::Inner(
pay(alice, bob,
XRP(10)), seq + 1),
850 batch::Inner(
pay(bob, alice,
XRP(5)), env.seq(bob)),
851 batch::Msig(bob, {carol, dave}),
862 auto const ledSeq = env.current()->seq();
863 auto const seq = env.seq(alice);
866 batch::Inner(
pay(alice, phantom,
XRP(1000)), seq + 1),
867 batch::Inner(
noop(phantom), ledSeq),
868 batch::Sig(
Reg{phantom, carol}),
875 auto const ledSeq = env.current()->seq();
876 auto const seq = env.seq(alice);
879 batch::Inner(
pay(alice, bob,
XRP(1000)), seq + 1),
880 batch::Inner(
noop(bob), ledSeq),
881 batch::Sig(
Reg{bob, carol}),
889 auto const seq = env.seq(alice);
892 batch::Inner(
pay(alice, bob,
XRP(1)), seq + 1),
893 batch::Inner(
pay(bob, alice,
XRP(2)), env.seq(bob)),
894 batch::Sig(
Reg{bob, carol}),
901 auto const seq = env.seq(alice);
904 batch::Inner(
pay(alice, bob,
XRP(1)), seq + 1),
905 batch::Inner(
pay(bob, alice,
XRP(2)), env.seq(bob)),
914 env(
fset(bob, asfDisableMaster),
Sig(bob));
915 auto const seq = env.seq(alice);
918 batch::Inner(
pay(alice, bob,
XRP(1)), seq + 1),
919 batch::Inner(
pay(bob, alice,
XRP(2)), env.seq(bob)),
934 Env env{*
this, features};
936 auto const alice =
Account(
"alice");
937 auto const bob =
Account(
"bob");
939 env.
fund(
XRP(10000), alice, bob);
947 auto const seq = env.
seq(alice);
949 tx1.removeMember(field);
958 return jt.
stx ==
nullptr;
967 BEAST_EXPECT(batchCtorFails(jss::TransactionType));
969 BEAST_EXPECT(batchCtorFails(jss::Account));
971 BEAST_EXPECT(batchCtorFails(jss::Sequence));
973 BEAST_EXPECT(batchCtorFails(jss::Fee));
975 BEAST_EXPECT(batchCtorFails(jss::SigningPubKey));
980 STAmount const mptAmt{issue, UINT64_C(100)};
983 auto const seq = env.
seq(alice);
986 tx1[jss::TransactionType] = jss::OfferCreate;
987 tx1[jss::Account] = alice.human();
1001 auto const seq = env.
seq(alice);
1003 auto tx1 =
pay(alice, bob,
XRP(10));
1004 auto& ma = tx1[
"Memos"];
1005 auto& mi = ma[ma.size()];
1006 auto& m = mi[
"Memo"];
1010 env(
batch::outer(alice, seq, batchFee, tfAllOrNothing),
1026 Env env{*
this, features};
1028 auto const alice =
Account(
"alice");
1029 auto const bob =
Account(
"bob");
1030 auto const gw =
Account(
"gw");
1031 auto const usd = gw[
"USD"];
1033 env.
fund(
XRP(10000), alice, bob, gw);
1035 env.
trust(usd(1000), alice, bob);
1036 env(
pay(gw, alice, usd(100)));
1037 env(
pay(gw, bob, usd(100)));
1045 auto const preAliceSeq = env.
seq(alice);
1046 auto const preAlice = env.
balance(alice);
1047 auto const preAliceUSD = env.
balance(alice, usd.issue());
1048 auto const preBobSeq = env.
seq(bob);
1049 auto const preBob = env.
balance(bob);
1050 auto const preBobUSD = env.
balance(bob, usd.issue());
1056 batch::outer(alice, preAliceSeq, batchFee, tfAllOrNothing),
1067 .result =
"tesSUCCESS",
1069 .batchID = std::nullopt,
1083 BEAST_EXPECT(env.
seq(alice) == preAliceSeq + 1);
1084 BEAST_EXPECT(env.
balance(alice) == preAlice - batchFee);
1085 BEAST_EXPECT(env.
balance(alice, usd.issue()) == preAliceUSD);
1086 BEAST_EXPECT(env.
seq(bob) == preBobSeq);
1087 BEAST_EXPECT(env.
balance(bob) == preBob);
1088 BEAST_EXPECT(env.
balance(bob, usd.issue()) == preBobUSD);
1093 auto const preAliceSeq = env.
seq(alice);
1094 auto const preAlice = env.
balance(alice);
1095 auto const preAliceUSD = env.
balance(alice, usd.issue());
1096 auto const preBobSeq = env.
seq(bob);
1097 auto const preBob = env.
balance(bob);
1098 auto const preBobUSD = env.
balance(bob, usd.issue());
1104 batch::outer(alice, preAliceSeq, batchFee, tfAllOrNothing),
1115 .result =
"tesSUCCESS",
1117 .batchID = std::nullopt,
1131 BEAST_EXPECT(env.
seq(alice) == preAliceSeq + 1);
1132 BEAST_EXPECT(env.
balance(alice) == preAlice - batchFee);
1133 BEAST_EXPECT(env.
balance(alice, usd.issue()) == preAliceUSD);
1134 BEAST_EXPECT(env.
seq(bob) == preBobSeq);
1135 BEAST_EXPECT(env.
balance(bob) == preBob);
1136 BEAST_EXPECT(env.
balance(bob, usd.issue()) == preBobUSD);
1141 auto const preAliceSeq = env.
seq(alice);
1142 auto const preAlice = env.
balance(alice);
1143 auto const preAliceUSD = env.
balance(alice, usd.issue());
1144 auto const preBobSeq = env.
seq(bob);
1145 auto const preBob = env.
balance(bob);
1146 auto const preBobUSD = env.
balance(bob, usd.issue());
1152 batch::outer(alice, preAliceSeq, batchFee, tfAllOrNothing),
1163 .result =
"tesSUCCESS",
1165 .batchID = std::nullopt,
1179 BEAST_EXPECT(env.
seq(alice) == preAliceSeq + 1);
1180 BEAST_EXPECT(env.
balance(alice) == preAlice - batchFee);
1181 BEAST_EXPECT(env.
balance(alice, usd.issue()) == preAliceUSD);
1182 BEAST_EXPECT(env.
seq(bob) == preBobSeq);
1183 BEAST_EXPECT(env.
balance(bob) == preBob);
1184 BEAST_EXPECT(env.
balance(bob, usd.issue()) == preBobUSD);
1189 auto const preAliceSeq = env.
seq(alice);
1190 auto const preAlice = env.
balance(alice);
1191 auto const preAliceUSD = env.
balance(alice, usd.issue());
1192 auto const preBobSeq = env.
seq(bob);
1193 auto const preBob = env.
balance(bob);
1194 auto const preBobUSD = env.
balance(bob, usd.issue());
1200 batch::outer(alice, preAliceSeq, batchFee, tfAllOrNothing),
1211 .result =
"tesSUCCESS",
1213 .batchID = std::nullopt,
1227 BEAST_EXPECT(env.
seq(alice) == preAliceSeq + 1);
1228 BEAST_EXPECT(env.
balance(alice) == preAlice - batchFee);
1229 BEAST_EXPECT(env.
balance(alice, usd.issue()) == preAliceUSD);
1230 BEAST_EXPECT(env.
seq(bob) == preBobSeq);
1231 BEAST_EXPECT(env.
balance(bob) == preBob);
1232 BEAST_EXPECT(env.
balance(bob, usd.issue()) == preBobUSD);
1237 auto const preAliceSeq = env.
seq(alice);
1238 auto const preAlice = env.
balance(alice);
1239 auto const preAliceUSD = env.
balance(alice, usd.issue());
1240 auto const preBobSeq = env.
seq(bob);
1241 auto const preBob = env.
balance(bob);
1242 auto const preBobUSD = env.
balance(bob, usd.issue());
1248 batch::outer(alice, preAliceSeq, batchFee, tfAllOrNothing),
1259 .result =
"tesSUCCESS",
1261 .batchID = std::nullopt,
1275 BEAST_EXPECT(env.
seq(alice) == preAliceSeq + 1);
1276 BEAST_EXPECT(env.
balance(alice) == preAlice - batchFee);
1277 BEAST_EXPECT(env.
balance(alice, usd.issue()) == preAliceUSD);
1278 BEAST_EXPECT(env.
seq(bob) == preBobSeq);
1279 BEAST_EXPECT(env.
balance(bob) == preBob);
1280 BEAST_EXPECT(env.
balance(bob, usd.issue()) == preBobUSD);
1294 Env env{*
this, features};
1296 auto const alice =
Account(
"alice");
1297 auto const bob =
Account(
"bob");
1298 env.
fund(
XRP(10000), alice, bob);
1306 auto const aliceSeq = env.
seq(alice);
1307 env(
batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
1316 Env env{*
this, features};
1318 auto const alice =
Account(
"alice");
1319 auto const bob =
Account(
"bob");
1320 auto const carol =
Account(
"carol");
1321 env.
fund(
XRP(10000), alice, bob, carol);
1327 env(
signers(alice, 2, {{bob, 1}, {carol, 1}}));
1332 auto const aliceSeq = env.
seq(alice);
1333 env(
batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
1343 Env env{*
this, features};
1345 auto const alice =
Account(
"alice");
1346 auto const bob =
Account(
"bob");
1347 auto const carol =
Account(
"carol");
1348 env.
fund(
XRP(10000), alice, bob, carol);
1354 env(
signers(alice, 2, {{bob, 1}, {carol, 1}}));
1359 auto const aliceSeq = env.
seq(alice);
1360 auto const bobSeq = env.
seq(bob);
1361 env(
batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
1372 Env env{*
this, features};
1374 auto const alice =
Account(
"alice");
1375 auto const bob =
Account(
"bob");
1376 auto const carol =
Account(
"carol");
1377 env.
fund(
XRP(10000), alice, bob, carol);
1383 env(
signers(alice, 2, {{bob, 1}, {carol, 1}}));
1386 env(
signers(bob, 2, {{alice, 1}, {carol, 1}}));
1391 auto const aliceSeq = env.
seq(alice);
1392 auto const bobSeq = env.
seq(bob);
1393 env(
batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
1404 Env env{*
this, features};
1406 auto const alice =
Account(
"alice");
1407 auto const bob =
Account(
"bob");
1408 env.
fund(
XRP(10000), alice, bob);
1416 auto const aliceSeq = env.
seq(alice);
1417 auto const bobSeq = env.
seq(bob);
1418 env(
batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
1428 Env env{*
this, features};
1430 auto const alice =
Account(
"alice");
1431 auto const bob =
Account(
"bob");
1432 auto const gw =
Account(
"gw");
1433 auto const usd = gw[
"USD"];
1435 env.
fund(
XRP(10000), alice, bob, gw);
1437 auto const ammCreate = [&alice](
STAmount const& amount,
STAmount const& amount2) {
1439 jv[jss::Account] = alice.human();
1442 jv[jss::TradingFee] = 0;
1443 jv[jss::TransactionType] = jss::AMMCreate;
1448 auto const seq = env.
seq(alice);
1449 env(
batch::outer(alice, seq, batchFee, tfAllOrNothing),
1467 Env env{*
this, features};
1469 auto const alice =
Account(
"alice");
1470 auto const bob =
Account(
"bob");
1471 env.
fund(
XRP(10000), alice, bob);
1475 auto const aliceSeq = env.
seq(alice);
1476 env(
batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
1494 Env env{*
this, features};
1496 auto const alice =
Account(
"alice");
1497 auto const bob =
Account(
"bob");
1498 env.
fund(
XRP(10000), alice, bob);
1502 auto const aliceSeq = env.
seq(alice);
1504 batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
1515 BEAST_EXPECT(jt.stx ==
nullptr);
1523 Env env{*
this, features};
1525 auto const alice =
Account(
"alice");
1526 auto const bob =
Account(
"bob");
1527 env.
fund(
XRP(10000), alice, bob);
1530 auto const aliceSeq = env.
seq(alice);
1536 batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
1552 BEAST_EXPECT(threw);
1564 Env env{*
this, features};
1566 auto const alice =
Account(
"alice");
1567 auto const bob =
Account(
"bob");
1568 env.
fund(
XRP(10000), alice, bob);
1574 auto const aliceSeq = env.
seq(alice);
1576 env(
batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
1587 Env env{*
this, features};
1589 auto const alice =
Account(
"alice");
1590 auto const bob =
Account(
"bob");
1591 env.
fund(
XRP(10000), alice, bob);
1595 auto const aliceSeq = env.
seq(alice);
1597 batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
1605 return result.applied;
1611 auto const [
valid, reason] =
1614 BEAST_EXPECT(reason ==
"BatchSigners array exceeds max entries.");
1626 Env env{*
this, features};
1628 auto const alice =
Account(
"alice");
1629 auto const bob =
Account(
"bob");
1630 auto const gw =
Account(
"gw");
1631 auto const usd = gw[
"USD"];
1632 env.
fund(
XRP(10000), alice, bob, gw);
1637 auto const preAlice = env.
balance(alice);
1638 auto const preBob = env.
balance(bob);
1641 auto const seq = env.
seq(alice);
1654 .result =
"tesSUCCESS",
1656 .batchID = std::nullopt,
1660 .txType =
"Payment",
1661 .result =
"tesSUCCESS",
1667 .txType =
"Payment",
1668 .result =
"tesSUCCESS",
1676 BEAST_EXPECT(env.
seq(alice) == seq + 3);
1679 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(3) - batchFee);
1680 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(3));
1685 auto const preAlice = env.
balance(alice);
1686 auto const preBob = env.
balance(bob);
1689 auto const seq = env.
seq(alice);
1704 .result =
"tesSUCCESS",
1706 .batchID = std::nullopt,
1712 BEAST_EXPECT(env.
seq(alice) == seq + 1);
1715 BEAST_EXPECT(env.
balance(alice) == preAlice - batchFee);
1716 BEAST_EXPECT(env.
balance(bob) == preBob);
1721 auto const preAlice = env.
balance(alice);
1722 auto const preBob = env.
balance(bob);
1725 auto const seq = env.
seq(alice);
1739 .result =
"tesSUCCESS",
1741 .batchID = std::nullopt,
1747 BEAST_EXPECT(env.
seq(alice) == seq + 1);
1750 BEAST_EXPECT(env.
balance(alice) == preAlice - batchFee);
1751 BEAST_EXPECT(env.
balance(bob) == preBob);
1756 auto const preAlice = env.
balance(alice);
1757 auto const preBob = env.
balance(bob);
1760 auto const seq = env.
seq(alice);
1774 .result =
"tesSUCCESS",
1776 .batchID = std::nullopt,
1782 BEAST_EXPECT(env.
seq(alice) == seq + 1);
1785 BEAST_EXPECT(env.
balance(alice) == preAlice - batchFee);
1786 BEAST_EXPECT(env.
balance(bob) == preBob);
1798 Env env{*
this, features};
1800 auto const alice =
Account(
"alice");
1801 auto const bob =
Account(
"bob");
1802 auto const carol =
Account(
"carol");
1803 auto const dave =
Account(
"dave");
1804 auto const gw =
Account(
"gw");
1805 auto const usd = gw[
"USD"];
1806 env.
fund(
XRP(10000), alice, bob, carol, dave, gw);
1811 auto const preAlice = env.
balance(alice);
1812 auto const preBob = env.
balance(bob);
1815 auto const seq = env.
seq(alice);
1832 .result =
"tesSUCCESS",
1834 .batchID = std::nullopt,
1838 .txType =
"Payment",
1839 .result =
"tecUNFUNDED_PAYMENT",
1845 .txType =
"Payment",
1846 .result =
"tecUNFUNDED_PAYMENT",
1852 .txType =
"Payment",
1853 .result =
"tecUNFUNDED_PAYMENT",
1861 BEAST_EXPECT(env.
seq(alice) == seq + 4);
1864 BEAST_EXPECT(env.
balance(alice) == preAlice - batchFee);
1865 BEAST_EXPECT(env.
balance(bob) == preBob);
1870 auto const preAlice = env.
balance(alice);
1871 auto const preBob = env.
balance(bob);
1874 auto const seq = env.
seq(alice);
1889 .result =
"tesSUCCESS",
1891 .batchID = std::nullopt,
1895 .txType =
"Payment",
1896 .result =
"tecUNFUNDED_PAYMENT",
1902 .txType =
"Payment",
1903 .result =
"tesSUCCESS",
1911 BEAST_EXPECT(env.
seq(alice) == seq + 3);
1914 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(1) - batchFee);
1915 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(1));
1920 auto const preAlice = env.
balance(alice);
1921 auto const preBob = env.
balance(bob);
1924 auto const seq = env.
seq(alice);
1939 .result =
"tesSUCCESS",
1941 .batchID = std::nullopt,
1945 .txType =
"Payment",
1946 .result =
"tesSUCCESS",
1954 BEAST_EXPECT(env.
seq(alice) == seq + 2);
1957 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(1) - batchFee);
1958 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(1));
1963 auto const preAlice = env.
balance(alice);
1964 auto const preBob = env.
balance(bob);
1967 auto const seq = env.
seq(alice);
1982 .result =
"tesSUCCESS",
1984 .batchID = std::nullopt,
1988 .txType =
"Payment",
1989 .result =
"tesSUCCESS",
1997 BEAST_EXPECT(env.
seq(alice) == seq + 2);
2000 BEAST_EXPECT(env.
balance(alice) == preAlice - batchFee -
XRP(1));
2001 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(1));
2006 auto const preAlice = env.
balance(alice);
2007 auto const preBob = env.
balance(bob);
2010 auto const seq = env.
seq(alice);
2025 .result =
"tesSUCCESS",
2027 .batchID = std::nullopt,
2031 .txType =
"Payment",
2032 .result =
"tesSUCCESS",
2040 BEAST_EXPECT(env.
seq(alice) == seq + 2);
2043 BEAST_EXPECT(env.
balance(alice) == preAlice - batchFee -
XRP(1));
2044 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(1));
2049 auto const preAlice = env.
balance(alice);
2050 auto const preBob = env.
balance(bob);
2051 auto const preCarol = env.
balance(carol);
2052 auto const seq = env.
seq(alice);
2060 offer(alice, alice[
"USD"](100),
XRP(100), tfImmediateOrCancel), seq + 1),
2062 offer(alice, alice[
"USD"](100),
XRP(100), tfImmediateOrCancel), seq + 2),
2064 offer(alice, alice[
"USD"](100),
XRP(100), tfImmediateOrCancel), seq + 3),
2074 .result =
"tesSUCCESS",
2076 .batchID = std::nullopt,
2080 .txType =
"OfferCreate",
2081 .result =
"tecKILLED",
2087 .txType =
"OfferCreate",
2088 .result =
"tecKILLED",
2094 .txType =
"OfferCreate",
2095 .result =
"tecKILLED",
2101 .txType =
"Payment",
2102 .result =
"tesSUCCESS",
2109 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(100) - batchFee);
2110 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(100));
2111 BEAST_EXPECT(env.
balance(carol) == preCarol);
2123 Env env{*
this, features};
2125 auto const alice =
Account(
"alice");
2126 auto const bob =
Account(
"bob");
2127 auto const carol =
Account(
"carol");
2128 auto const dave =
Account(
"dave");
2129 auto const gw =
Account(
"gw");
2130 auto const usd = gw[
"USD"];
2131 env.
fund(
XRP(10000), alice, bob, carol, dave, gw);
2136 auto const preAlice = env.
balance(alice);
2137 auto const preBob = env.
balance(bob);
2140 auto const seq = env.
seq(alice);
2156 .result =
"tesSUCCESS",
2158 .batchID = std::nullopt,
2162 .txType =
"Payment",
2163 .result =
"tecUNFUNDED_PAYMENT",
2171 BEAST_EXPECT(env.
seq(alice) == seq + 2);
2174 BEAST_EXPECT(env.
balance(alice) == preAlice - batchFee);
2175 BEAST_EXPECT(env.
balance(bob) == preBob);
2180 auto const preAlice = env.
balance(alice);
2181 auto const preBob = env.
balance(bob);
2184 auto const seq = env.
seq(alice);
2199 .result =
"tesSUCCESS",
2201 .batchID = std::nullopt,
2205 .txType =
"Payment",
2206 .result =
"tesSUCCESS",
2212 .txType =
"Payment",
2213 .result =
"tesSUCCESS",
2219 .txType =
"Payment",
2220 .result =
"tesSUCCESS",
2226 .txType =
"Payment",
2227 .result =
"tesSUCCESS",
2235 BEAST_EXPECT(env.
seq(alice) == seq + 5);
2238 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(10) - batchFee);
2239 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(10));
2244 auto const preAlice = env.
balance(alice);
2245 auto const preBob = env.
balance(bob);
2248 auto const seq = env.
seq(alice);
2264 .result =
"tesSUCCESS",
2266 .batchID = std::nullopt,
2270 .txType =
"Payment",
2271 .result =
"tesSUCCESS",
2277 .txType =
"Payment",
2278 .result =
"tesSUCCESS",
2284 .txType =
"Payment",
2285 .result =
"tecUNFUNDED_PAYMENT",
2293 BEAST_EXPECT(env.
seq(alice) == seq + 4);
2296 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(3) - batchFee);
2297 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(3));
2302 auto const preAlice = env.
balance(alice);
2303 auto const preBob = env.
balance(bob);
2306 auto const seq = env.
seq(alice);
2322 .result =
"tesSUCCESS",
2324 .batchID = std::nullopt,
2328 .txType =
"Payment",
2329 .result =
"tesSUCCESS",
2335 .txType =
"Payment",
2336 .result =
"tesSUCCESS",
2344 BEAST_EXPECT(env.
seq(alice) == seq + 3);
2347 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(3) - batchFee);
2348 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(3));
2353 auto const preAlice = env.
balance(alice);
2354 auto const preBob = env.
balance(bob);
2357 auto const seq = env.
seq(alice);
2373 .result =
"tesSUCCESS",
2375 .batchID = std::nullopt,
2379 .txType =
"Payment",
2380 .result =
"tesSUCCESS",
2386 .txType =
"Payment",
2387 .result =
"tesSUCCESS",
2395 BEAST_EXPECT(env.
seq(alice) == seq + 3);
2398 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(3) - batchFee);
2399 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(3));
2404 auto const preAlice = env.
balance(alice);
2405 auto const preBob = env.
balance(bob);
2406 auto const preCarol = env.
balance(carol);
2407 auto const seq = env.
seq(alice);
2416 offer(alice, alice[
"USD"](100),
XRP(100), tfImmediateOrCancel), seq + 3),
2424 .result =
"tesSUCCESS",
2426 .batchID = std::nullopt,
2430 .txType =
"Payment",
2431 .result =
"tesSUCCESS",
2437 .txType =
"Payment",
2438 .result =
"tesSUCCESS",
2444 .txType =
"OfferCreate",
2445 .result =
"tecKILLED",
2452 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(200) - batchFee);
2453 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(100));
2454 BEAST_EXPECT(env.
balance(carol) == preCarol +
XRP(100));
2466 Env env{*
this, features};
2468 auto const alice =
Account(
"alice");
2469 auto const bob =
Account(
"bob");
2470 auto const carol =
Account(
"carol");
2471 auto const gw =
Account(
"gw");
2472 auto const usd = gw[
"USD"];
2473 env.
fund(
XRP(10000), alice, bob, carol, gw);
2478 auto const preAlice = env.
balance(alice);
2479 auto const preBob = env.
balance(bob);
2482 auto const seq = env.
seq(alice);
2499 .result =
"tesSUCCESS",
2501 .batchID = std::nullopt,
2505 .txType =
"Payment",
2506 .result =
"tesSUCCESS",
2512 .txType =
"Payment",
2513 .result =
"tecUNFUNDED_PAYMENT",
2519 .txType =
"Payment",
2520 .result =
"tecUNFUNDED_PAYMENT",
2526 .txType =
"Payment",
2527 .result =
"tesSUCCESS",
2535 BEAST_EXPECT(env.
seq(alice) == seq + 5);
2538 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(4) - batchFee);
2539 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(4));
2544 auto const preAlice = env.
balance(alice);
2545 auto const preBob = env.
balance(bob);
2548 auto const seq = env.
seq(alice);
2564 .result =
"tesSUCCESS",
2566 .batchID = std::nullopt,
2570 .txType =
"Payment",
2571 .result =
"tesSUCCESS",
2577 .txType =
"Payment",
2578 .result =
"tesSUCCESS",
2584 .txType =
"Payment",
2585 .result =
"tecUNFUNDED_PAYMENT",
2591 .txType =
"Payment",
2592 .result =
"tesSUCCESS",
2600 BEAST_EXPECT(env.
seq(alice) == seq + 5);
2603 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(6) - batchFee);
2604 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(6));
2609 auto const preAlice = env.
balance(alice);
2610 auto const preBob = env.
balance(bob);
2613 auto const seq = env.
seq(alice);
2629 .result =
"tesSUCCESS",
2631 .batchID = std::nullopt,
2635 .txType =
"Payment",
2636 .result =
"tesSUCCESS",
2642 .txType =
"Payment",
2643 .result =
"tesSUCCESS",
2649 .txType =
"Payment",
2650 .result =
"tesSUCCESS",
2658 BEAST_EXPECT(env.
seq(alice) == seq + 4);
2661 BEAST_EXPECT(env.
balance(alice) == preAlice - batchFee -
XRP(6));
2662 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(6));
2667 auto const preAlice = env.
balance(alice);
2668 auto const preBob = env.
balance(bob);
2671 auto const seq = env.
seq(alice);
2687 .result =
"tesSUCCESS",
2689 .batchID = std::nullopt,
2693 .txType =
"Payment",
2694 .result =
"tesSUCCESS",
2700 .txType =
"Payment",
2701 .result =
"tesSUCCESS",
2707 .txType =
"Payment",
2708 .result =
"tesSUCCESS",
2716 BEAST_EXPECT(env.
seq(alice) == seq + 4);
2719 BEAST_EXPECT(env.
balance(alice) == preAlice - batchFee -
XRP(6));
2720 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(6));
2725 auto const preAlice = env.
balance(alice);
2726 auto const preBob = env.
balance(bob);
2727 auto const preCarol = env.
balance(carol);
2728 auto const seq = env.
seq(alice);
2737 offer(alice, alice[
"USD"](100),
XRP(100), tfImmediateOrCancel), seq + 3));
2744 .result =
"tesSUCCESS",
2746 .batchID = std::nullopt,
2750 .txType =
"Payment",
2751 .result =
"tesSUCCESS",
2757 .txType =
"Payment",
2758 .result =
"tesSUCCESS",
2764 .txType =
"OfferCreate",
2765 .result =
"tecKILLED",
2772 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(200) - batchFee);
2773 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(100));
2774 BEAST_EXPECT(env.
balance(carol) == preCarol +
XRP(100));
2782 std::string(
"inner submit rpc: batch ") + (withBatch ?
"enabled" :
"disabled") +
": ";
2784 auto const amend = withBatch ? features : features - featureBatchV1_1;
2789 Env env{*
this, amend};
2790 if (!BEAST_EXPECT(amend[featureBatchV1_1] == withBatch))
2793 auto const alice =
Account(
"alice");
2794 auto const bob =
Account(
"bob");
2796 env.
fund(
XRP(10000), alice, bob);
2806 jrr[jss::status] ==
"error" && jrr[jss::error] ==
"invalidTransaction" &&
2807 !jrr.isMember(jss::error_code) && jrr[jss::error_message].isNull() &&
2808 jrr[jss::error_exception] ==
2809 "fails local checks: Batch inner transactions are never "
2810 "considered validly signed.",
2824 txn[sfTxnSignature] =
"DEADBEEF";
2828 submitAndValidate(
"TxnSignature set", s.
slice(), __LINE__);
2838 txn[sfSigningPubKey] =
strHex(alice.pk());
2842 submitAndValidate(
"SigningPubKey set", s.
slice(), __LINE__);
2856 submitAndValidate(
"Signers set", s.
slice(), __LINE__);
2862 auto const jt = env.
jt(txn.getTxn());
2867 submitAndValidate(
"Fully signed", s.
slice(), __LINE__);
2880 submitAndValidate(
"No signing fields set", s.
slice(), __LINE__);
2889 STTx const amendTx(ttAMENDMENT, [seq = env.
closed()->header().seq + 1](
auto& obj) {
2890 obj.setAccountID(sfAccount, AccountID());
2891 obj.setFieldH256(sfAmendment, featureBatchV1_1);
2892 obj.setFieldU32(sfLedgerSequence, seq);
2893 obj.setFieldU32(sfFlags, tfInnerBatchTxn);
2900 submitAndValidate(
"Pseudo-transaction", s.
slice(), __LINE__);
2907 for (
bool const withBatch : {
true,
false})
2921 Env env{*
this, features};
2923 auto const alice =
Account(
"alice");
2924 auto const bob =
Account(
"bob");
2929 auto const preAlice = env.
balance(alice);
2930 auto const ledSeq = env.
current()->seq();
2931 auto const seq = env.
seq(alice);
2946 .result =
"tesSUCCESS",
2948 .batchID = std::nullopt,
2952 .txType =
"Payment",
2953 .result =
"tesSUCCESS",
2959 .txType =
"AccountSet",
2960 .result =
"tesSUCCESS",
2968 BEAST_EXPECT(env.
seq(alice) == seq + 2);
2971 BEAST_EXPECT(env.
seq(bob) == ledSeq + 1);
2974 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(1000) - batchFee);
2985 Env env{*
this, features};
2987 auto const alice =
Account(
"alice");
2988 auto const gw =
Account(
"gw");
2989 auto const carol =
Account(
"carol");
2990 auto const usd = gw[
"USD"];
2991 env.
fund(
XRP(10000), alice, gw);
2995 env(
trust(alice, usd(100000)));
2996 env(
pay(gw, alice, usd(10000)));
2997 env(
offer(gw, usd(2000),
XRP(2000)));
3000 auto const seq = env.
seq(alice);
3003 auto pp =
pay(alice, carol,
XRP(1000));
3005 pp[jss::Flags] = tfPartialPayment;
3014 BEAST_EXPECT(!env.
le(carol));
3031 Env env{*
this, features};
3033 auto const alice =
Account(
"alice");
3036 auto const unfunded =
Account(
"aaa");
3037 auto const carol =
Account(
"carol");
3038 env.
fund(
XRP(10000), alice, carol);
3042 BEAST_EXPECT(unfunded.id() < carol.id());
3044 auto const seq = env.
seq(alice);
3045 auto const ledSeq = env.
current()->seq();
3056 env(
batch::outer(alice, seq, batchFee, tfAllOrNothing),
3073 Env env{*
this, features};
3075 auto const alice =
Account(
"alice");
3076 auto const bob =
Account(
"bob");
3077 env.
fund(
XRP(10000), alice, bob);
3080 auto const preAlice = env.
balance(alice);
3081 auto const preBob = env.
balance(bob);
3083 auto const seq = env.
seq(alice);
3087 tx1[sfDomain] =
strHex(domain);
3100 .result =
"tesSUCCESS",
3102 .batchID = std::nullopt,
3106 .txType =
"AccountSet",
3107 .result =
"tesSUCCESS",
3113 .txType =
"Payment",
3114 .result =
"tesSUCCESS",
3123 BEAST_EXPECT(sle->getFieldVL(sfDomain) ==
Blob(domain.
begin(), domain.
end()));
3126 BEAST_EXPECT(env.
seq(alice) == seq + 3);
3129 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(1) - batchFee);
3130 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(1));
3143 Env env{*
this, features};
3145 auto const alice =
Account(
"alice");
3146 auto const bob =
Account(
"bob");
3147 env.
fund(
XRP(10000), alice, bob);
3151 for (
int i = 0; i < 5; ++i)
3154 auto const preAlice = env.
balance(alice);
3155 auto const preBob = env.
balance(bob);
3157 auto const seq = env.
seq(alice);
3173 .result =
"tesSUCCESS",
3175 .batchID = std::nullopt,
3179 .txType =
"Payment",
3180 .result =
"tesSUCCESS",
3186 .txType =
"AccountDelete",
3187 .result =
"tesSUCCESS",
3196 BEAST_EXPECT(env.
balance(bob) == preBob + (preAlice - batchFee));
3201 Env env{*
this, features};
3203 auto const alice =
Account(
"alice");
3204 auto const bob =
Account(
"bob");
3205 env.
fund(
XRP(10000), alice, bob);
3209 for (
int i = 0; i < 5; ++i)
3212 auto const preAlice = env.
balance(alice);
3213 auto const preBob = env.
balance(bob);
3215 env.
trust(bob[
"USD"](1000), alice);
3218 auto const seq = env.
seq(alice);
3234 .result =
"tesSUCCESS",
3236 .batchID = std::nullopt,
3240 .txType =
"Payment",
3241 .result =
"tesSUCCESS",
3247 .txType =
"AccountDelete",
3248 .result =
"tecHAS_OBLIGATIONS",
3254 .txType =
"Payment",
3255 .result =
"tesSUCCESS",
3264 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(3));
3269 Env env{*
this, features};
3271 auto const alice =
Account(
"alice");
3272 auto const bob =
Account(
"bob");
3273 env.
fund(
XRP(10000), alice, bob);
3277 for (
int i = 0; i < 5; ++i)
3280 auto const preAlice = env.
balance(alice);
3281 auto const preBob = env.
balance(bob);
3283 auto const seq = env.
seq(alice);
3299 .result =
"tesSUCCESS",
3301 .batchID = std::nullopt,
3308 BEAST_EXPECT(env.
balance(bob) == preBob);
3317 bool const lendingBatchEnabled = features[featureLendingProtocolV1_2];
3321 Env env{*
this, features};
3323 Account const issuer{
"issuer"};
3326 Account const lender{
"lender"};
3328 Account const borrower{
"borrower"};
3338 Vault const vault{env};
3340 auto const deposit = asset(50'000);
3341 auto const debtMaximumValue = asset(25'000).value();
3342 auto const coverDepositValue = asset(1000).value();
3348 auto [tx, vaultKeylet, subscriptionDate] =
3349 vault.createClosedEnded({.owner = lender, .asset = asset});
3352 BEAST_EXPECT(env.
le(vaultKeylet));
3354 env(vault.deposit({.depositor = lender, .id = vaultKeylet.key, .amount = deposit}));
3358 vault.closePastSubscription(subscriptionDate);
3360 auto const brokerKeylet =
3365 env(
set(lender, vaultKeylet.key),
3367 kDebtMaximum(debtMaximumValue),
3371 env(coverDeposit(lender, brokerKeylet.key, coverDepositValue));
3377 using namespace loan;
3378 using namespace std::chrono_literals;
3380 auto const lenderSeq = env.
seq(lender);
3388 batch::outer(lender, lenderSeq, batchFee, tfAllOrNothing),
3391 set(lender, brokerKeylet.key, asset(1000).value()),
3393 Sig(sfCounterpartySignature, borrower),
3399 pay(lender, loanKeylet.key,
STAmount{asset, asset(500).value()}),
3406 batch::outer(lender, lenderSeq, batchFee, tfAllOrNothing),
3409 set(lender, brokerKeylet.key, asset(1000).value()),
3416 pay(lender, loanKeylet.key,
STAmount{asset, asset(500).value()}),
3423 batch::outer(lender, lenderSeq, batchFee, tfAllOrNothing),
3426 set(lender, brokerKeylet.key, asset(1000).value()),
3428 kCounterparty(borrower.
id()),
3434 pay(lender, loanKeylet.key,
STAmount{asset, asset(500).value()}),
3445 batch::outer(lender, lenderSeq, batchFee, tfAllOrNothing),
3448 set(lender, brokerKeylet.key, asset(1000).value()),
3449 kCounterparty(borrower.
id()),
3461 STAmount{asset, asset(500).value()}),
3466 BEAST_EXPECT(!env.
le(loanKeylet));
3467 auto const brokerSleBefore = env.
le(brokerKeylet);
3468 if (!BEAST_EXPECT(brokerSleBefore))
3470 auto const coverAvailableBefore = brokerSleBefore->at(sfCoverAvailable);
3471 auto const coverDepositAmount = asset(100).value();
3476 auto const lenderSeq = env.
seq(lender);
3481 batch::outer(lender, lenderSeq, batchFee, tfAllOrNothing),
3484 set(lender, brokerKeylet.key, asset(1000).value()),
3485 kCounterparty(borrower.
id()),
3496 BEAST_EXPECT(
static_cast<bool>(env.
le(loanKeylet)) == lendingBatchEnabled);
3497 if (
auto const brokerSle = env.
le(brokerKeylet); BEAST_EXPECT(brokerSle))
3499 auto const expectedCover = lendingBatchEnabled
3500 ? coverAvailableBefore + coverDepositAmount
3501 : coverAvailableBefore;
3502 BEAST_EXPECT(brokerSle->at(sfCoverAvailable) == expectedCover);
3515 auto const checkVaultBatch = [
this](
FeatureBitset amendments) {
3516 bool const lendingBatchEnabled = amendments[featureLendingProtocolV1_2];
3517 Env env{*
this, amendments};
3520 Account const lender{
"lender"};
3521 env.
fund(
XRP(100'000), payer, lender);
3524 Vault const vault{env};
3525 auto [
create, vaultKeylet] = vault.create({.owner = lender, .asset =
xrpIssue()});
3527 auto const payerSeq = env.
seq(payer);
3528 auto const lenderSeq = env.
seq(lender);
3533 batch::outer(payer, payerSeq, batchFee, tfAllOrNothing),
3537 {.depositor = lender, .id = vaultKeylet.key, .amount = XRP(1'000)}),
3542 BEAST_EXPECT(
static_cast<bool>(env.
le(vaultKeylet)) == lendingBatchEnabled);
3545 checkVaultBatch(features - featureLendingProtocolV1_2);
3546 checkVaultBatch(features);
3552 testcase(
"object create w/ sequence");
3557 Env env{*
this, features};
3559 auto const alice =
Account(
"alice");
3560 auto const bob =
Account(
"bob");
3561 auto const gw =
Account(
"gw");
3562 auto const usd = gw[
"USD"];
3564 env.
fund(
XRP(10000), alice, bob, gw);
3567 env.
trust(usd(1000), alice, bob);
3568 env(
pay(gw, alice, usd(100)));
3569 env(
pay(gw, bob, usd(100)));
3574 auto const aliceSeq = env.
seq(alice);
3575 auto const bobSeq = env.
seq(bob);
3576 auto const preAlice = env.
balance(alice);
3577 auto const preBob = env.
balance(bob);
3578 auto const preAliceUSD = env.
balance(alice, usd.issue());
3579 auto const preBobUSD = env.
balance(bob, usd.issue());
3586 batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
3596 .result =
"tesSUCCESS",
3598 .batchID = std::nullopt,
3602 .txType =
"CheckCreate",
3603 .result =
"tesSUCCESS",
3609 .txType =
"CheckCash",
3610 .result =
"tesSUCCESS",
3618 BEAST_EXPECT(env.
seq(alice) == aliceSeq + 2);
3621 BEAST_EXPECT(env.
seq(bob) == bobSeq + 1);
3624 BEAST_EXPECT(env.
balance(alice) == preAlice - batchFee);
3625 BEAST_EXPECT(env.
balance(bob) == preBob);
3628 BEAST_EXPECT(env.
balance(alice, usd.issue()) == preAliceUSD + usd(10));
3629 BEAST_EXPECT(env.
balance(bob, usd.issue()) == preBobUSD - usd(10));
3634 env(
fset(alice, asfRequireDest));
3637 auto const aliceSeq = env.
seq(alice);
3638 auto const bobSeq = env.
seq(bob);
3639 auto const preAlice = env.
balance(alice);
3640 auto const preBob = env.
balance(bob);
3641 auto const preAliceUSD = env.
balance(alice, usd.issue());
3642 auto const preBobUSD = env.
balance(bob, usd.issue());
3649 batch::outer(alice, aliceSeq, batchFee, tfIndependent),
3660 .result =
"tesSUCCESS",
3662 .batchID = std::nullopt,
3666 .txType =
"CheckCreate",
3667 .result =
"tecDST_TAG_NEEDED",
3673 .txType =
"CheckCash",
3674 .result =
"tecNO_ENTRY",
3682 BEAST_EXPECT(env.
seq(alice) == aliceSeq + 2);
3685 BEAST_EXPECT(env.
seq(bob) == bobSeq + 1);
3688 BEAST_EXPECT(env.
balance(alice) == preAlice - batchFee);
3689 BEAST_EXPECT(env.
balance(bob) == preBob);
3692 BEAST_EXPECT(env.
balance(alice, usd.issue()) == preAliceUSD);
3693 BEAST_EXPECT(env.
balance(bob, usd.issue()) == preBobUSD);
3700 testcase(
"object create w/ ticket");
3705 Env env{*
this, features};
3707 auto const alice =
Account(
"alice");
3708 auto const bob =
Account(
"bob");
3709 auto const gw =
Account(
"gw");
3710 auto const usd = gw[
"USD"];
3712 env.
fund(
XRP(10000), alice, bob, gw);
3715 env.
trust(usd(1000), alice, bob);
3716 env(
pay(gw, alice, usd(100)));
3717 env(
pay(gw, bob, usd(100)));
3720 auto const aliceSeq = env.
seq(alice);
3721 auto const bobSeq = env.
seq(bob);
3722 auto const preAlice = env.
balance(alice);
3723 auto const preBob = env.
balance(bob);
3724 auto const preAliceUSD = env.
balance(alice, usd.issue());
3725 auto const preBobUSD = env.
balance(bob, usd.issue());
3732 batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
3743 .result =
"tesSUCCESS",
3745 .batchID = std::nullopt,
3749 .txType =
"TicketCreate",
3750 .result =
"tesSUCCESS",
3756 .txType =
"CheckCreate",
3757 .result =
"tesSUCCESS",
3763 .txType =
"CheckCash",
3764 .result =
"tesSUCCESS",
3771 BEAST_EXPECT(env.
seq(alice) == aliceSeq + 2);
3772 BEAST_EXPECT(env.
seq(bob) == bobSeq + 10 + 1);
3773 BEAST_EXPECT(env.
balance(alice) == preAlice - batchFee);
3774 BEAST_EXPECT(env.
balance(bob) == preBob);
3775 BEAST_EXPECT(env.
balance(alice, usd.issue()) == preAliceUSD + usd(10));
3776 BEAST_EXPECT(env.
balance(bob, usd.issue()) == preBobUSD - usd(10));
3782 testcase(
"object create w/ 3rd party");
3787 Env env{*
this, features};
3789 auto const alice =
Account(
"alice");
3790 auto const bob =
Account(
"bob");
3791 auto const carol =
Account(
"carol");
3792 auto const gw =
Account(
"gw");
3793 auto const usd = gw[
"USD"];
3795 env.
fund(
XRP(10000), alice, bob, carol, gw);
3798 env.
trust(usd(1000), alice, bob);
3799 env(
pay(gw, alice, usd(100)));
3800 env(
pay(gw, bob, usd(100)));
3803 auto const aliceSeq = env.
seq(alice);
3804 auto const bobSeq = env.
seq(bob);
3805 auto const carolSeq = env.
seq(carol);
3806 auto const preAlice = env.
balance(alice);
3807 auto const preBob = env.
balance(bob);
3808 auto const preCarol = env.
balance(carol);
3809 auto const preAliceUSD = env.
balance(alice, usd.issue());
3810 auto const preBobUSD = env.
balance(bob, usd.issue());
3817 batch::outer(carol, carolSeq, batchFee, tfAllOrNothing),
3827 .result =
"tesSUCCESS",
3829 .batchID = std::nullopt,
3833 .txType =
"CheckCreate",
3834 .result =
"tesSUCCESS",
3840 .txType =
"CheckCash",
3841 .result =
"tesSUCCESS",
3848 BEAST_EXPECT(env.
seq(alice) == aliceSeq + 1);
3849 BEAST_EXPECT(env.
seq(bob) == bobSeq + 1);
3850 BEAST_EXPECT(env.
seq(carol) == carolSeq + 1);
3851 BEAST_EXPECT(env.
balance(alice) == preAlice);
3852 BEAST_EXPECT(env.
balance(bob) == preBob);
3853 BEAST_EXPECT(env.
balance(carol) == preCarol - batchFee);
3854 BEAST_EXPECT(env.
balance(alice, usd.issue()) == preAliceUSD + usd(10));
3855 BEAST_EXPECT(env.
balance(bob, usd.issue()) == preBobUSD - usd(10));
3867 Env env{*
this, features};
3869 auto const alice =
Account(
"alice");
3870 auto const bob =
Account(
"bob");
3872 env.
fund(
XRP(10000), alice, bob);
3879 auto const aliceSeq = env.
seq(alice);
3880 auto const preAlice = env.
balance(alice);
3881 auto const preBob = env.
balance(bob);
3897 .result =
"tesSUCCESS",
3899 .batchID = std::nullopt,
3903 .txType =
"Payment",
3904 .result =
"tesSUCCESS",
3910 .txType =
"Payment",
3911 .result =
"tesSUCCESS",
3920 BEAST_EXPECT(sle->getFieldU32(sfOwnerCount) == 9);
3921 BEAST_EXPECT(sle->getFieldU32(sfTicketCount) == 9);
3923 BEAST_EXPECT(env.
seq(alice) == aliceSeq + 2);
3924 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(3) - batchFee);
3925 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(3));
3934 Env env{*
this, features};
3936 auto const alice =
Account(
"alice");
3937 auto const bob =
Account(
"bob");
3939 env.
fund(
XRP(10000), alice, bob);
3946 auto const aliceSeq = env.
seq(alice);
3947 auto const preAlice = env.
balance(alice);
3948 auto const preBob = env.
balance(bob);
3954 batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
3963 .result =
"tesSUCCESS",
3965 .batchID = std::nullopt,
3969 .txType =
"Payment",
3970 .result =
"tesSUCCESS",
3976 .txType =
"Payment",
3977 .result =
"tesSUCCESS",
3986 BEAST_EXPECT(sle->getFieldU32(sfOwnerCount) == 8);
3987 BEAST_EXPECT(sle->getFieldU32(sfTicketCount) == 8);
3989 BEAST_EXPECT(env.
seq(alice) == aliceSeq + 1);
3990 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(3) - batchFee);
3991 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(3));
4000 Env env{*
this, features};
4002 auto const alice =
Account(
"alice");
4003 auto const bob =
Account(
"bob");
4005 env.
fund(
XRP(10000), alice, bob);
4012 auto const aliceSeq = env.
seq(alice);
4013 auto const preAlice = env.
balance(alice);
4014 auto const preBob = env.
balance(bob);
4030 .result =
"tesSUCCESS",
4032 .batchID = std::nullopt,
4036 .txType =
"Payment",
4037 .result =
"tesSUCCESS",
4043 .txType =
"Payment",
4044 .result =
"tesSUCCESS",
4053 BEAST_EXPECT(sle->getFieldU32(sfOwnerCount) == 8);
4054 BEAST_EXPECT(sle->getFieldU32(sfTicketCount) == 8);
4056 BEAST_EXPECT(env.
seq(alice) == aliceSeq + 1);
4057 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(3) - batchFee);
4058 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(3));
4070 auto const alice =
Account(
"alice");
4071 auto const bob =
Account(
"bob");
4072 auto const carol =
Account(
"carol");
4081 Env env{*
this, features};
4082 env.
fund(
XRP(10000), alice, bob, carol);
4085 auto const aliceSeq = env.
seq(alice);
4086 auto const carolSeq = env.
seq(carol);
4089 auto const noopTxn = env.
jt(
noop(alice),
Seq(aliceSeq + 2));
4090 auto const noopTxnID =
to_string(noopTxn.stx->getTransactionID());
4098 batch::outer(carol, carolSeq, batchFee, tfAllOrNothing),
4109 .result =
"tesSUCCESS",
4111 .batchID = std::nullopt,
4115 .txType =
"Payment",
4116 .result =
"tesSUCCESS",
4122 .txType =
"Payment",
4123 .result =
"tesSUCCESS",
4137 .txType =
"AccountSet",
4138 .result =
"tesSUCCESS",
4139 .txHash = noopTxnID,
4140 .batchID = std::nullopt,
4152 Env env{*
this, features};
4153 env.
fund(
XRP(10000), alice, bob);
4156 auto const aliceSeq = env.
seq(alice);
4159 auto const noopTxn = env.
jt(
noop(alice),
Seq(aliceSeq + 1));
4167 batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
4177 .result =
"tesSUCCESS",
4179 .batchID = std::nullopt,
4183 .txType =
"Payment",
4184 .result =
"tesSUCCESS",
4190 .txType =
"Payment",
4191 .result =
"tesSUCCESS",
4212 Env env{*
this, features};
4213 env.
fund(
XRP(10000), alice, bob);
4216 auto const aliceSeq = env.
seq(alice);
4221 batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
4225 auto const noopTxn = env.
jt(
noop(alice),
Seq(aliceSeq + 1));
4234 .result =
"tesSUCCESS",
4236 .batchID = std::nullopt,
4240 .txType =
"Payment",
4241 .result =
"tesSUCCESS",
4247 .txType =
"Payment",
4248 .result =
"tesSUCCESS",
4266 Env env{*
this, features};
4267 env.
fund(
XRP(10000), alice, bob, carol);
4270 auto const aliceSeq = env.
seq(alice);
4271 auto const carolSeq = env.
seq(carol);
4278 batch::outer(carol, carolSeq + 1, batchFee, tfAllOrNothing),
4284 auto const noopTxn = env.
jt(
noop(carol),
Seq(carolSeq));
4285 auto const noopTxnID =
to_string(noopTxn.stx->getTransactionID());
4293 .txType =
"AccountSet",
4294 .result =
"tesSUCCESS",
4295 .txHash = noopTxnID,
4296 .batchID = std::nullopt,
4301 .result =
"tesSUCCESS",
4303 .batchID = std::nullopt,
4307 .txType =
"Payment",
4308 .result =
"tesSUCCESS",
4314 .txType =
"Payment",
4315 .result =
"tesSUCCESS",
4340 auto const alice =
Account(
"alice");
4341 auto const bob =
Account(
"bob");
4348 Env env{*
this, features};
4349 env.
fund(
XRP(10000), alice, bob);
4356 auto const aliceSeq = env.
seq(alice);
4378 .result =
"tesSUCCESS",
4380 .batchID = std::nullopt,
4384 .txType =
"Payment",
4385 .result =
"tesSUCCESS",
4391 .txType =
"Payment",
4392 .result =
"tesSUCCESS",
4413 Env env{*
this, features};
4414 env.
fund(
XRP(10000), alice, bob);
4421 auto const aliceSeq = env.
seq(alice);
4443 .result =
"tesSUCCESS",
4445 .batchID = std::nullopt,
4449 .txType =
"Payment",
4450 .result =
"tesSUCCESS",
4456 .txType =
"Payment",
4457 .result =
"tesSUCCESS",
4482 auto const alice =
Account(
"alice");
4483 auto const bob =
Account(
"bob");
4492 Env env{*
this, features};
4493 env.
fund(
XRP(10000), alice, bob);
4500 auto const aliceSeq = env.
seq(alice);
4505 auto const objTxnID =
to_string(objTxn.stx->getTransactionID());
4524 .result =
"tesSUCCESS",
4526 .batchID = std::nullopt,
4530 .txType =
"CheckCreate",
4531 .result =
"tesSUCCESS",
4537 .txType =
"Payment",
4538 .result =
"tesSUCCESS",
4544 .txType =
"CheckCash",
4545 .result =
"tesSUCCESS",
4547 .batchID = std::nullopt,
4563 Env env{*
this, features};
4564 env.
fund(
XRP(10000), alice, bob);
4571 auto const aliceSeq = env.
seq(alice);
4572 auto const bobSeq = env.
seq(bob);
4577 auto const objTxnID =
to_string(objTxn.stx->getTransactionID());
4596 .txType =
"CheckCreate",
4597 .result =
"tesSUCCESS",
4599 .batchID = std::nullopt,
4604 .result =
"tesSUCCESS",
4606 .batchID = std::nullopt,
4610 .txType =
"CheckCash",
4611 .result =
"tesSUCCESS",
4617 .txType =
"Payment",
4618 .result =
"tesSUCCESS",
4634 Env env{*
this, features};
4635 env.
fund(
XRP(10000), alice, bob);
4642 auto const aliceSeq = env.
seq(alice);
4657 auto const objTxnID =
to_string(objTxn.stx->getTransactionID());
4666 .result =
"tesSUCCESS",
4668 .batchID = std::nullopt,
4672 .txType =
"CheckCreate",
4673 .result =
"tesSUCCESS",
4679 .txType =
"Payment",
4680 .result =
"tesSUCCESS",
4686 .txType =
"CheckCash",
4687 .result =
"tesSUCCESS",
4689 .batchID = std::nullopt,
4700 testcase(
"pseudo txn with tfInnerBatchTxn");
4705 Env env{*
this, features};
4707 auto const alice =
Account(
"alice");
4708 auto const bob =
Account(
"bob");
4709 env.
fund(
XRP(10000), alice, bob);
4712 STTx const stx =
STTx(ttAMENDMENT, [&](
auto& obj) {
4713 obj.setAccountID(sfAccount,
AccountID());
4714 obj.setFieldH256(sfAmendment,
UInt256(2));
4715 obj.setFieldU32(sfLedgerSequence, env.
seq(alice));
4722 BEAST_EXPECT(reason ==
"Cannot submit pseudo transactions.");
4726 return result.applied;
4744 Env env{*
this, features};
4747 auto const alice =
Account(
"alice");
4748 auto const bob =
Account(
"bob");
4750 env.
fund(
XRP(10000), alice, bob);
4756 auto const aliceSeq = env.
seq(alice);
4757 auto const preAlice = env.
balance(alice);
4758 auto const preBob = env.
balance(bob);
4759 auto const bobSeq = env.
seq(bob);
4762 auto const payTxn1 = env.
jt(
pay(alice, bob,
XRP(10)),
Seq(aliceSeq));
4763 auto const payTxn1ID =
to_string(payTxn1.stx->getTransactionID());
4771 batch::outer(alice, aliceSeq + 1, batchFee, tfAllOrNothing),
4777 auto const payTxn2 = env.
jt(
pay(bob, alice,
XRP(5)),
Seq(bobSeq + 1));
4778 auto const payTxn2ID =
to_string(payTxn2.stx->getTransactionID());
4785 .txType =
"Payment",
4786 .result =
"tesSUCCESS",
4787 .txHash = payTxn1ID,
4788 .batchID = std::nullopt,
4793 .result =
"tesSUCCESS",
4795 .batchID = std::nullopt,
4799 .txType =
"Payment",
4800 .result =
"tesSUCCESS",
4806 .txType =
"Payment",
4807 .result =
"tesSUCCESS",
4820 .txType =
"Payment",
4821 .result =
"tesSUCCESS",
4822 .txHash = payTxn2ID,
4823 .batchID = std::nullopt,
4830 BEAST_EXPECT(env.
seq(alice) == aliceSeq + 3);
4833 BEAST_EXPECT(env.
seq(bob) == bobSeq + 2);
4836 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(10) - batchFee - baseFee);
4837 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(10) - baseFee);
4843 testcase(
"inner txns not in open ledger");
4847 Env env{*
this, features};
4849 auto const alice =
Account(
"alice");
4850 auto const bob =
Account(
"bob");
4851 env.
fund(
XRP(10000), alice, bob);
4854 auto const aliceSeq = env.
seq(alice);
4855 auto const bobSeq = env.
seq(bob);
4857 auto const batchTxn = env.
jt(
4858 batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
4864 auto const batchID = batchTxn.stx->getTransactionID();
4865 auto const innerIDs = batchTxn.stx->getBatchTransactionIDs();
4868 auto const expectOnlyOuterInOpenLedger = [&] {
4870 BEAST_EXPECT(
std::distance(view->txs.begin(), view->txs.end()) == 1);
4871 BEAST_EXPECT(view->txExists(batchID));
4872 for (
auto const&
id : innerIDs)
4873 BEAST_EXPECT(!view->txExists(
id));
4874 for (
auto const& [tx, meta] : view->txs)
4876 BEAST_EXPECT(env.
seq(bob) == bobSeq);
4878 expectOnlyOuterInOpenLedger();
4893 BEAST_EXPECT(retries.empty());
4894 expectOnlyOuterInOpenLedger();
4899 auto const closed = env.closed();
4900 BEAST_EXPECT(closed->txExists(batchID));
4901 for (
auto const&
id : innerIDs)
4902 BEAST_EXPECT(closed->txExists(
id));
4903 BEAST_EXPECT(env.seq(bob) == bobSeq + 1);
4926 auto const alice =
Account(
"alice");
4927 auto const bob =
Account(
"bob");
4928 auto const carol =
Account(
"carol");
4932 env.
close(env.
now() + 5s, 10000ms);
4934 env.
close(env.
now() + 5s, 10000ms);
4945 auto const aliceSeq = env.
seq(alice);
4946 auto const bobSeq = env.
seq(bob);
4951 env(
batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
4977 auto const alice =
Account(
"alice");
4978 auto const bob =
Account(
"bob");
4979 auto const carol =
Account(
"carol");
4983 env.
close(env.
now() + 5s, 10000ms);
4985 env.
close(env.
now() + 5s, 10000ms);
4992 auto const aliceSeq = env.
seq(alice);
4993 auto const bobSeq = env.
seq(bob);
4998 env(
batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
5022 auto const alice =
Account(
"alice");
5023 auto const bob =
Account(
"bob");
5026 env.
close(env.
now() + 5s, 10000ms);
5034 auto const aliceSeq = env.
seq(alice);
5043 auto const bobSeq = env.
seq(bob);
5045 env(
batch::outer(alice, aliceSeq + 2, batchFee, tfAllOrNothing),
5066 auto alice =
Account(
"alice");
5068 env.
fund(
XRP(10000), alice, bob);
5076 return jt.stx->getTransactionID();
5087 return transaction->getID();
5108 testcase(
"batch delegate consent");
5125 Env env{*
this, features};
5127 auto const alice =
Account(
"alice");
5128 auto const bob =
Account(
"bob");
5129 auto const mallory =
Account(
"mallory");
5130 env.
fund(
XRP(10000), alice, bob, mallory);
5136 auto const preMallory = env.
balance(mallory);
5139 auto const seq = env.
seq(alice);
5142 inner[jss::Delegate] = bob.human();
5145 env(
batch::outer(alice, seq, batchFee, tfAllOrNothing),
5152 BEAST_EXPECT(env.
balance(mallory) == preMallory);
5166 Env env{*
this, features};
5168 auto const alice =
Account(
"alice");
5169 auto const bob =
Account(
"bob");
5170 auto const mallory =
Account(
"mallory");
5171 env.
fund(
XRP(10000), alice, bob, mallory);
5174 auto const preMallory = env.
balance(mallory);
5177 auto const seq = env.
seq(alice);
5180 inner[jss::Delegate] = bob.human();
5182 env(
batch::outer(alice, seq, batchFee, tfAllOrNothing),
5188 BEAST_EXPECT(env.
balance(mallory) == preMallory);
5194 Env env{*
this, features};
5196 auto const alice =
Account(
"alice");
5197 auto const bob =
Account(
"bob");
5198 auto const mallory =
Account(
"mallory");
5199 env.
fund(
XRP(10000), alice, bob, mallory);
5202 auto const preMallory = env.
balance(mallory);
5205 auto const seq = env.
seq(alice);
5208 inner[jss::Delegate] = bob.human();
5210 env(
batch::outer(alice, seq, batchFee, tfAllOrNothing),
5217 BEAST_EXPECT(env.
balance(mallory) == preMallory +
XRP(1000));
5223 Env env{*
this, features};
5225 auto const alice =
Account(
"alice");
5226 auto const bob =
Account(
"bob");
5227 auto const carol =
Account(
"carol");
5228 env.
fund(
XRP(10000), alice, bob, carol);
5234 auto const preAlice = env.
balance(alice);
5237 auto const aliceSeq = env.
seq(alice);
5238 auto const bobSeq = env.
seq(bob);
5241 inner[jss::Delegate] = carol.human();
5244 env(
batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
5250 BEAST_EXPECT(env.
balance(alice) == preAlice);
5256 Env env{*
this, features};
5258 auto const alice =
Account(
"alice");
5259 auto const bob =
Account(
"bob");
5260 auto const carol =
Account(
"carol");
5261 auto const mallory =
Account(
"mallory");
5262 env.
fund(
XRP(10000), alice, bob, carol, mallory);
5268 auto const preMallory = env.
balance(mallory);
5271 auto const seq = env.
seq(alice);
5274 inner[jss::Delegate] = bob.human();
5277 env(
batch::outer(alice, seq, batchFee, tfAllOrNothing),
5284 BEAST_EXPECT(env.
balance(mallory) == preMallory);
5290 Env env{*
this, features};
5292 auto const alice =
Account(
"alice");
5293 auto const bob =
Account(
"bob");
5294 env.
fund(
XRP(10000), alice, bob);
5301 auto const preBob = env.
balance(bob);
5304 auto const aliceSeq = env.
seq(alice);
5305 auto const bobSeq = env.
seq(bob);
5308 inner[jss::Delegate] = alice.human();
5310 env(
batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
5317 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(1));
5325 Env env{*
this, features};
5327 auto const alice =
Account(
"alice");
5328 auto const bob =
Account(
"bob");
5329 auto const carol =
Account(
"carol");
5330 env.
fund(
XRP(10000), alice, bob, carol);
5336 auto const preAlice = env.
balance(alice);
5339 auto const aliceSeq = env.
seq(alice);
5340 auto const bobSeq = env.
seq(bob);
5343 inner[jss::Delegate] = carol.human();
5346 env(
batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
5353 BEAST_EXPECT(env.
balance(alice) == preAlice);
5361 Env env{*
this, features};
5363 auto const alice =
Account(
"alice");
5364 auto const bob =
Account(
"bob");
5365 auto const mallory =
Account(
"mallory");
5366 env.
fund(
XRP(10000), alice, bob, mallory);
5372 auto const preMallory = env.
balance(mallory);
5375 auto const seq = env.
seq(bob);
5378 inner2[jss::Delegate] = alice.human();
5395 .result =
"tesSUCCESS",
5397 .batchID = std::nullopt,
5401 .txType =
"Payment",
5402 .result =
"tesSUCCESS",
5408 .txType =
"Payment",
5409 .result =
"tesSUCCESS",
5417 BEAST_EXPECT(env.
balance(mallory) == preMallory +
XRP(1000));
5427 Env env{*
this, features};
5429 auto const alice =
Account(
"alice");
5430 auto const bob =
Account(
"bob");
5431 auto const mallory =
Account(
"mallory");
5432 env.
fund(
XRP(10000), alice, bob, mallory);
5438 auto const preMallory = env.
balance(mallory);
5441 auto const seq = env.
seq(bob);
5446 inner2[jss::Delegate] = alice.human();
5464 .result =
"tesSUCCESS",
5466 .batchID = std::nullopt,
5470 .txType =
"DelegateSet",
5471 .result =
"tesSUCCESS",
5480 BEAST_EXPECT(env.
balance(mallory) == preMallory);
5481 auto const txResult = env.
rpc(
"tx", txIDs[1])[jss::result];
5482 BEAST_EXPECT(txResult[jss::error] ==
"txnNotFound");
5484 BEAST_EXPECT(txResult[jss::error_message] ==
"Transaction not found.");
5498 Env env{*
this, features};
5500 auto const alice =
Account(
"alice");
5501 auto const bob =
Account(
"bob");
5502 auto const gw =
Account(
"gw");
5503 auto const usd = gw[
"USD"];
5504 env.
fund(
XRP(10000), alice, bob, gw);
5510 auto const preAlice = env.
balance(alice);
5511 auto const preBob = env.
balance(bob);
5514 auto const seq = env.
seq(alice);
5517 tx[jss::Delegate] = bob.human();
5533 .result =
"tesSUCCESS",
5535 .batchID = std::nullopt,
5539 .txType =
"Payment",
5540 .result =
"tesSUCCESS",
5546 .txType =
"Payment",
5547 .result =
"tesSUCCESS",
5555 BEAST_EXPECT(env.
seq(alice) == seq + 3);
5558 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(3) - batchFee);
5559 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(3));
5564 Env env{*
this, features};
5566 auto const alice =
Account(
"alice");
5567 auto const bob =
Account(
"bob");
5568 auto const carol =
Account(
"carol");
5569 auto const gw =
Account(
"gw");
5570 auto const usd = gw[
"USD"];
5571 env.
fund(
XRP(10000), alice, bob, carol, gw);
5577 auto const preAlice = env.
balance(alice);
5578 auto const preBob = env.
balance(bob);
5579 auto const preCarol = env.
balance(carol);
5582 auto const aliceSeq = env.
seq(alice);
5583 auto const bobSeq = env.
seq(bob);
5586 tx[jss::Delegate] = carol.human();
5592 batch::outer(alice, aliceSeq, batchFee, tfAllOrNothing),
5602 .result =
"tesSUCCESS",
5604 .batchID = std::nullopt,
5608 .txType =
"Payment",
5609 .result =
"tesSUCCESS",
5615 .txType =
"Payment",
5616 .result =
"tesSUCCESS",
5623 BEAST_EXPECT(env.
seq(alice) == aliceSeq + 2);
5624 BEAST_EXPECT(env.
seq(bob) == bobSeq + 1);
5625 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(1) - batchFee);
5626 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(1));
5629 BEAST_EXPECT(env.
balance(carol) == preCarol);
5636 Env env{*
this, features};
5638 auto const alice =
Account(
"alice");
5639 auto const bob =
Account(
"bob");
5640 auto const gw =
Account(
"gw");
5641 auto const usd = gw[
"USD"];
5642 env.
fund(
XRP(10000), alice, bob, gw);
5648 auto const preAlice = env.
balance(alice);
5649 auto const preBob = env.
balance(bob);
5652 auto const seq = env.
seq(alice);
5656 tx[sfDomain.jsonName] =
strHex(domain);
5657 tx[jss::Delegate] = bob.human();
5673 .result =
"tesSUCCESS",
5675 .batchID = std::nullopt,
5679 .txType =
"AccountSet",
5680 .result =
"tesSUCCESS",
5686 .txType =
"Payment",
5687 .result =
"tesSUCCESS",
5695 BEAST_EXPECT(env.
seq(alice) == seq + 3);
5698 BEAST_EXPECT(env.
balance(alice) == preAlice -
XRP(2) - batchFee);
5699 BEAST_EXPECT(env.
balance(bob) == preBob +
XRP(2));
5706 Env env{*
this, features};
5709 env.
fund(
XRP(100000), alice, bob);
5713 MPTTester mpt(env, alice, {.fund =
false});
5715 mpt.create({.flags = tfMPTCanLock});
5719 env(
delegate::set(alice, bob, {
"MPTokenIssuanceLock",
"MPTokenIssuanceUnlock"}));
5722 auto const seq = env.
seq(alice);
5726 jv1[sfTransactionType] = jss::MPTokenIssuanceSet;
5727 jv1[sfAccount] = alice.
human();
5728 jv1[sfDelegate] = bob.
human();
5729 jv1[sfSequence] = seq + 1;
5730 jv1[sfMPTokenIssuanceID] =
to_string(mptID);
5731 jv1[sfFlags] = tfMPTLock;
5734 jv2[sfTransactionType] = jss::MPTokenIssuanceSet;
5735 jv2[sfAccount] = alice.
human();
5736 jv2[sfDelegate] = bob.
human();
5737 jv2[sfSequence] = seq + 2;
5738 jv2[sfMPTokenIssuanceID] =
to_string(mptID);
5739 jv2[sfFlags] = tfMPTUnlock;
5756 .result =
"tesSUCCESS",
5758 .batchID = std::nullopt,
5762 .txType =
"MPTokenIssuanceSet",
5763 .result =
"tesSUCCESS",
5769 .txType =
"MPTokenIssuanceSet",
5770 .result =
"tesSUCCESS",
5782 Env env{*
this, features};
5786 env.
fund(
XRP(10000), gw, alice, bob);
5787 env(
fset(gw, asfRequireAuth));
5789 env(
trust(alice, gw[
"USD"](50)));
5792 env(
delegate::set(gw, bob, {
"TrustlineAuthorize",
"TrustlineFreeze"}));
5795 auto const seq = env.
seq(gw);
5798 auto jv1 =
trust(gw, gw[
"USD"](0), alice, tfSetfAuth);
5799 jv1[sfDelegate] = bob.
human();
5800 auto jv2 =
trust(gw, gw[
"USD"](0), alice, tfSetFreeze);
5801 jv2[sfDelegate] = bob.
human();
5818 .result =
"tesSUCCESS",
5820 .batchID = std::nullopt,
5824 .txType =
"TrustSet",
5825 .result =
"tesSUCCESS",
5831 .txType =
"TrustSet",
5832 .result =
"tesSUCCESS",
5842 Env env{*
this, features};
5846 env.
fund(
XRP(10000), gw, alice, bob);
5847 env(
fset(gw, asfRequireAuth));
5849 env(
trust(alice, gw[
"USD"](50)));
5852 env(
delegate::set(gw, bob, {
"TrustlineAuthorize",
"TrustlineFreeze"}));
5855 auto const seq = env.
seq(gw);
5858 auto jv1 =
trust(gw, gw[
"USD"](0), alice, tfSetFreeze);
5859 jv1[sfDelegate] = bob.
human();
5860 auto jv2 =
trust(gw, gw[
"USD"](0), alice, tfClearFreeze);
5861 jv2[sfDelegate] = bob.
human();
5879 .result =
"tesSUCCESS",
5881 .batchID = std::nullopt,
5885 .txType =
"TrustSet",
5886 .result =
"tesSUCCESS",
5895 auto const txResult = env.
rpc(
"tx", txIDs[1])[jss::result];
5896 BEAST_EXPECT(txResult[jss::error] ==
"txnNotFound");
5898 BEAST_EXPECT(txResult[jss::error_message] ==
"Transaction not found.");
5910 using namespace jtx;
5911 Env env(*
this, features);
5914 env.
fund(
XRP(10000), alice, bob);
5919 auto const baseFee = env.
current()->fees().base;
5920 auto const aliceSeq = env.
seq(alice);
5925 auto const jr = env.
rpc(
"submit",
strHex(s.
slice()))[jss::result];
5928 BEAST_EXPECT(jr.isMember(jss::account_sequence_available));
5929 BEAST_EXPECT(jr[jss::account_sequence_available].asUInt() == aliceSeq + 1);
5930 BEAST_EXPECT(jr.isMember(jss::account_sequence_next));
5931 BEAST_EXPECT(jr[jss::account_sequence_next].asUInt() == aliceSeq + 1);
5932 BEAST_EXPECT(jr.isMember(jss::open_ledger_cost));
5933 BEAST_EXPECT(jr[jss::open_ledger_cost] ==
to_string(baseFee));
5934 BEAST_EXPECT(jr.isMember(jss::validated_ledger_index));
5939 auto const baseFee = env.
current()->fees().base;
5940 auto const aliceSeq = env.
seq(alice);
5941 env(
fset(bob, asfRequireDest));
5946 auto const jr = env.
rpc(
"submit",
strHex(s.
slice()))[jss::result];
5949 BEAST_EXPECT(jr.isMember(jss::account_sequence_available));
5950 BEAST_EXPECT(jr[jss::account_sequence_available].asUInt() == aliceSeq + 1);
5951 BEAST_EXPECT(jr.isMember(jss::account_sequence_next));
5952 BEAST_EXPECT(jr[jss::account_sequence_next].asUInt() == aliceSeq + 1);
5953 BEAST_EXPECT(jr.isMember(jss::open_ledger_cost));
5954 BEAST_EXPECT(jr[jss::open_ledger_cost] ==
to_string(baseFee));
5955 BEAST_EXPECT(jr.isMember(jss::validated_ledger_index));
5960 auto const baseFee = env.
current()->fees().base;
5961 auto const aliceSeq = env.
seq(alice);
5962 auto const jtx = env.
jt(
pay(alice, bob,
XRP(1)),
Seq(aliceSeq + 1));
5966 auto const jr = env.
rpc(
"submit",
strHex(s.
slice()))[jss::result];
5969 BEAST_EXPECT(jr.isMember(jss::account_sequence_available));
5970 BEAST_EXPECT(jr[jss::account_sequence_available].asUInt() == aliceSeq);
5971 BEAST_EXPECT(jr.isMember(jss::account_sequence_next));
5972 BEAST_EXPECT(jr[jss::account_sequence_next].asUInt() == aliceSeq);
5973 BEAST_EXPECT(jr.isMember(jss::open_ledger_cost));
5974 BEAST_EXPECT(jr[jss::open_ledger_cost] ==
to_string(baseFee));
5975 BEAST_EXPECT(jr.isMember(jss::validated_ledger_index));
5982 using namespace jtx;
5983 Env env(*
this, features);
5987 env.
fund(
XRP(10000), alice, bob, carol);
5999 auto const seq = env.
seq(alice);
6001 auto const jtx = env.
jt(
6005 BEAST_EXPECT(
jtx.stx ==
nullptr);
6011 auto const seq = env.
seq(alice);
6014 auto const jtx = env.
jt(
6026 BEAST_EXPECT(
jtx.stx ==
nullptr);
6031 auto const seq = env.
seq(alice);
6034 auto const jtx = env.
jt(
6041 BEAST_EXPECT(txBaseFee == env.
current()->fees().base);
6046 auto const seq = env.
seq(alice);
6048 auto const jtx = env.
jt(
6053 BEAST_EXPECT(txBaseFee == batchFee);
6060 testcase(
"standalone tx with tfInnerBatchTxn rejected");
6069 Env env{*
this, features};
6071 auto const alice =
Account(
"alice");
6072 auto const bob =
Account(
"bob");
6073 env.
fund(
XRP(10000), alice, bob);
6087 STTx const stx =
STTx(ttPAYMENT, [&](
auto& obj) {
6088 obj.setAccountID(sfAccount, alice.id());
6089 obj.setAccountID(sfDestination, bob.id());
6090 obj.setFieldAmount(sfAmount,
XRP(1));
6091 obj.setFieldAmount(sfFee,
XRP(0));
6092 obj.setFieldU32(sfSequence, env.
seq(alice));
6098 BEAST_EXPECT(!result.applied);
6114 Env env{*
this, features};
6116 auto const alice =
Account(
"alice");
6117 auto const bob =
Account(
"bob");
6118 auto const carol =
Account(
"carol");
6119 auto const eve =
Account(
"eve");
6120 env.
fund(
XRP(10000), alice, bob, carol, eve);
6123 auto const preCarol = env.
balance(carol);
6124 auto const bobSeq = env.
seq(bob);
6125 auto const carolSeq = env.
seq(carol);
6127 auto const aliceSeq = env.
seq(alice);
6135 auto const capturedSigners = jt1.
jv[sfBatchSigners.jsonName];
6139 BEAST_EXPECT(env.
seq(bob) == bobSeq + 1);
6140 BEAST_EXPECT(env.
seq(carol) == carolSeq);
6148 jt2.
jv[sfBatchSigners.jsonName] = capturedSigners;
6152 BEAST_EXPECT(env.
seq(carol) == carolSeq);
6153 BEAST_EXPECT(env.
balance(carol) == preCarol);
6159 Env env{*
this, features};
6161 auto const alice =
Account(
"alice");
6162 auto const bob =
Account(
"bob");
6163 auto const carol =
Account(
"carol");
6164 env.
fund(
XRP(10000), alice, bob, carol);
6167 auto const preCarol = env.
balance(carol);
6168 auto const bobSeq = env.
seq(bob);
6169 auto const carolSeq = env.
seq(carol);
6171 auto const aliceSeq1 = env.
seq(alice);
6179 auto const capturedSigners = jt1.
jv[sfBatchSigners.jsonName];
6183 BEAST_EXPECT(env.
seq(bob) == bobSeq + 1);
6184 BEAST_EXPECT(env.
seq(carol) == carolSeq);
6192 jt2.
jv[sfBatchSigners.jsonName] = capturedSigners;
6196 BEAST_EXPECT(env.
balance(carol) == preCarol);
6197 BEAST_EXPECT(env.
seq(carol) == carolSeq);
6203 Env env{*
this, features};
6205 auto const alice =
Account(
"alice");
6206 auto const bob =
Account(
"bob");
6207 auto const carol =
Account(
"carol");
6208 auto const dave =
Account(
"dave");
6209 auto const elsa =
Account(
"elsa");
6210 env.
fund(
XRP(10000), alice, bob, carol, dave, elsa);
6213 env(
signers(bob, 2, {{dave, 1}, {elsa, 1}}));
6215 env(
signers(carol, 2, {{dave, 1}, {elsa, 1}}));
6218 auto const seq = env.
seq(alice);
6227 auto const bobSignerEntry = jt1.
jv[sfBatchSigners.jsonName][0u];
6232 auto const seq2 = env.
seq(alice);
6240 carolSigner[sfBatchSigner.jsonName][jss::Account] = carol.human();
6241 carolSigner[sfBatchSigner.jsonName][jss::SigningPubKey] =
"";
6242 carolSigner[sfBatchSigner.jsonName][sfSigners.jsonName] =
6243 bobSignerEntry[sfBatchSigner.jsonName][sfSigners.jsonName];
6245 jt2.jv[sfBatchSigners.jsonName][0u] = carolSigner;
6254 testcase(
"unsorted batch signers");
6258 Env env{*
this, features};
6260 auto const alice =
Account(
"alice");
6261 auto const bob =
Account(
"bob");
6262 auto const carol =
Account(
"carol");
6263 env.
fund(
XRP(10000), alice, bob, carol);
6266 auto const seq = env.
seq(alice);
6267 auto const bobSeq = env.
seq(bob);
6268 auto const carolSeq = env.
seq(carol);
6277 auto const s0 = jt.
jv[sfBatchSigners.jsonName][0u];
6278 auto const s1 = jt.jv[sfBatchSigners.jsonName][1u];
6279 jt.jv[sfBatchSigners.jsonName][0u] = s1;
6280 jt.jv[sfBatchSigners.jsonName][1u] = s0;
6289 testcase(
"batch signature caching");
6299 auto const buildValidBatch = [](
Env& env) {
6300 auto const alice =
Account(
"alice");
6301 auto const bob =
Account(
"bob");
6302 auto const seq = env.seq(alice);
6313 Env env{*
this, features};
6317 auto const jt = buildValidBatch(env);
6318 auto const txid = jt.stx->getTransactionID();
6329 Env env{*
this, features};
6333 auto jt = buildValidBatch(env);
6334 jt.jv[sfBatchSigners.jsonName][0u][sfBatchSigner.jsonName][sfTxnSignature.jsonName] =
6341 Env env{*
this, features};
6345 auto jt = buildValidBatch(env);
6346 jt.jv[sfBatchSigners.jsonName][0u][sfBatchSigner.jsonName][sfTxnSignature.jsonName] =
6358 testcase(
"wrapper field submission");
6364 for (
SField const* wrapper : {
6375 &sfTransactionMetaData,
6378 bool const poisoned = (wrapper != &sfRawTransaction);
6380 auto const alice =
Account(
"alice");
6381 auto const bob =
Account(
"bob");
6385 inner[jss::SigningPubKey] =
"";
6386 inner[jss::Sequence] = s;
6387 inner[jss::Fee] =
"0";
6391 wrapped[wrapper->jsonName] = inner;
6395 auto const submit = [&](
Env& env,
TER const expected) {
6396 env.
fund(
XRP(10000), alice, bob);
6399 auto const preBob = env.
balance(bob);
6401 auto const seq = env.
seq(alice);
6403 auto jv =
batch::outer(alice, seq, batchFee, tfAllOrNothing);
6404 jv[jss::RawTransactions][0u] = wrap(seq + 1);
6405 jv[jss::RawTransactions][1u] = wrap(seq + 2);
6407 env(jv,
Ter(expected));
6415 Env env{*
this, features - fixBatchV1_2};
6418 wrapper->getName() +
" did not execute without fixBatchV1_2");
6423 Env env{*
this, features | fixBatchV1_2};
6426 delivered == !poisoned, wrapper->getName() +
" wrong result with fixBatchV1_2");
A generic endpoint for log messages.
bool expect(Condition const &shouldBeTrue)
Evaluate a test condition.
void fail(String const &reason, char const *file, int line)
Record a failure.
TestcaseT testcase
Memberspace for declaring test cases.
Lightweight wrapper to tag static string.
static XRPAmount calculateBaseFee(ReadView const &view, STTx const &tx)
bool setFlags(UInt256 const &key, HashRouterFlags flags)
Set the flags on a hash.
HashRouterFlags getFlags(UInt256 const &key)
std::shared_ptr< Ledger const > getClosedLedger()
The finalized ledger is the last closed/accepted ledger.
virtual void submitTransaction(std::shared_ptr< STTx const > const &)=0
virtual void processTransaction(std::shared_ptr< Transaction > &transaction, bool bUnlimited, bool bLocal, FailHard failType)=0
Process transactions as they arrive from the network or which are submitted by clients.
void accept(Application &app, Rules const &rules, std::shared_ptr< Ledger const > const &ledger, OrderedTxs const &locals, bool retriesFirst, OrderedTxs &retries, ApplyFlags flags, std::string_view suffix="", ModifyType const &f={})
Accept a new ledger.
std::shared_ptr< OpenView const > current() const
Returns a view to the current open ledger.
bool modify(ModifyType const &f)
Modify the open ledger.
Writable ledger view that accumulates state and tx changes.
json::Value getJson(JsonOptions=JsonOptions::Values::None) const override
Holds the serialized result of parsing an input JSON object.
std::optional< STObject > object
The STObject if the parse was successful.
UInt256 getTransactionID() const
json::Value getJson(JsonOptions options) const override
static constexpr SeqProxy rawSequence(std::uint32_t v)
Factory function to return a sequence-based SeqProxy.
Slice slice() const noexcept
virtual NetworkOPs & getOPs()=0
virtual OpenLedger & getOpenLedger()=0
virtual LedgerMaster & getLedgerMaster()=0
virtual HashRouter & getHashRouter()=0
An immutable linear range of bytes.
static NotTEC invokePreflight(PreflightContext const &ctx)
Metrics getMetrics(OpenView const &view) const
Returns fee metrics in reference fee level units.
void testOpenLedger(FeatureBitset features)
void testLendingAmendment(FeatureBitset features)
void testWrappedInnerSubmission(FeatureBitset features)
void testBatchDelegateConsent(FeatureBitset features)
void testTicketsOpenLedger(FeatureBitset features)
static json::Value getLastLedger(jtx::Env &env)
void run() override
Runs the suite.
void testBadRawTxn(FeatureBitset features)
void testObjectsOpenLedger(FeatureBitset features)
void testStandaloneInnerBatchFlag(FeatureBitset features)
void testSequenceOpenLedger(FeatureBitset features)
void testEnable(FeatureBitset features)
void testPreflight(FeatureBitset features)
void testInnerTxnsNotInOpenLedger(FeatureBitset features)
void testObjectCreate3rdParty(FeatureBitset features)
static UInt256 getCheckIndex(AccountID const &account, std::uint32_t uSequence)
void testIndependent(FeatureBitset features)
void doTestInnerSubmitRPC(FeatureBitset features, bool withBatch)
void testBatchDelegate(FeatureBitset features)
void testBadSequence(FeatureBitset features)
void testTickets(FeatureBitset features)
void testAccountSet(FeatureBitset features)
std::pair< std::vector< std::string >, std::string > submitBatch(jtx::Env &env, TER const &result, Args &&... args)
void testPreclaim(FeatureBitset features)
void testBatchTxQueue(FeatureBitset features)
static auto openLedgerFee(jtx::Env &env, XRPAmount const &batchFee)
void testAllOrNothing(FeatureBitset features)
void testCheckAllSignatures(FeatureBitset features)
void testValidateRPCResponse(FeatureBitset features)
void testWithFeats(FeatureBitset features)
void testBatchCalculateBaseFee(FeatureBitset features)
void testLoan(FeatureBitset features)
void testOuterBinding(FeatureBitset features)
void testBatchNetworkOps(FeatureBitset features)
static json::Value getTxByIndex(json::Value const &jrr, int const index)
void testObjectCreateTicket(FeatureBitset features)
void testInnerSubmitRPC(FeatureBitset features)
void validateClosedLedger(jtx::Env &env, std::vector< TestLedgerData > const &ledgerResults)
void testCalculateBaseFee(FeatureBitset features)
void testAccountActivation(FeatureBitset features)
void testUntilFailure(FeatureBitset features)
void testObjectCreateSequence(FeatureBitset features)
void testOnlyOne(FeatureBitset features)
static std::unique_ptr< Config > makeSmallQueueConfig(std::map< std::string, std::string > extraTxQ={}, std::map< std::string, std::string > extraVoting={})
void testAccountDelete(FeatureBitset features)
void testUnsortedBatchSigners(FeatureBitset features)
void testPseudoTxn(FeatureBitset features)
void testBadOuterFee(FeatureBitset features)
void testBatchSigCache(FeatureBitset features)
Immutable cryptographic account descriptor.
std::string const & human() const
Returns the human readable public key.
AccountID id() const
Returns the Account ID.
A transaction testing environment.
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
json::Value json(JsonValue &&jv, FN const &... fN)
Create JSON from parameters.
SLE::const_pointer le(Account const &account) const
Return an account root.
std::shared_ptr< ReadView const > closed()
Returns the last closed ledger.
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
ParseFailureGuard getParseFailureGuard(bool b)
Gets an RAII guard to set and restore the parse failure flag.
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.
JTx jt(JsonValue &&jv, FN const &... fN)
Create a JTx from parameters.
PrettyAmount balance(Account const &account) const
Returns the XRP balance on an account.
void trust(STAmount const &amount, Account const &account)
Establish trust lines.
JTx jtnofill(JsonValue &&jv, FN const &... fN)
Create a JTx from parameters.
void memoize(Account const &account)
Associate AccountID with account.
beast::Journal const journal
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
NetClock::time_point now()
Returns the current network time.
Test helper for creating, mutating, and asserting MPT and confidential MPT ledger state.
Set a multisignature on a JTx.
Set the regular signature on a JTx.
Set the expected result code for a JTx The test will fail if the code doesn't match.
Adds an inner Batch transaction to a JTx and autofills it.
Sets a nested multi-signature for a Batch transaction on a JTx.
Sets the Batch transaction signers on a JTx.
Set a ticket sequence on a JTx.
@ Array
array value (ordered list)
@ Object
object value (collection of name/value pairs).
TER valid(STTx const &tx, ReadView const &view, AccountID const &src, beast::Journal j)
Keylet check(AccountID const &id, SeqProxy const &seq) noexcept
A Check.
Keylet loanBroker(AccountID const &owner, SeqProxy const &seq) noexcept
Keylet account(AccountID const &id) noexcept
AccountID root.
Keylet loan(UInt256 const &loanBrokerID, SeqProxy const &loanSeq) noexcept
void validateInnerTxn(Env &env, std::string const &batchID, std::string const &txHash, std::string const &txType, std::string const &result, std::source_location const &loc=std::source_location::current())
Expect an inner Batch transaction to be recorded with the given type and result, and with ParentBatch...
json::Value outer(jtx::Account const &account, uint32_t seq, STAmount const &fee, std::uint32_t flags)
Build an outer Batch transaction JSON object.
XRPAmount calcBatchFee(jtx::Env const &env, uint32_t const &numSigners, uint32_t const &txns=0)
Calculate the expected outer Batch transaction fee.
json::Value cash(jtx::Account const &dest, UInt256 const &checkId, STAmount const &amount)
Cash a check requiring that a specific amount be delivered.
json::Value create(A const &account, A const &dest, STAmount const &sendMax)
Create a check.
json::Value set(jtx::Account const &account, jtx::Account const &authorize, std::vector< std::string > const &permissions)
Deposit preauthorize operations.
json::Value coverDeposit(AccountID const &account, UInt256 const &brokerID, STAmount const &amount, uint32_t flags)
json::Value create(AccountID const &account, AccountID const &to, STAmount const &amount, NetClock::duration const &settleDelay, PublicKey const &pk, std::optional< NetClock::time_point > const &cancelAfter, std::optional< std::uint32_t > const &dstTag)
json::Value create(Account const &account, std::uint32_t count)
Create one of more tickets.
json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
json::Value regkey(Account const &account, DisabledT)
Disable the regular key.
XrpT const XRP
Converts to XRP Issue or STAmount.
json::Value noop(Account const &account)
The null transaction.
void checkMetrics(Suite &test, jtx::Env &env, std::size_t expectedCount, std::optional< std::size_t > expectedMaxCount, std::size_t expectedInLedger, std::size_t expectedPerLedger, std::uint64_t expectedMinFeeLevel=kBaseFeeLevel.fee(), std::uint64_t expectedMedFeeLevel=kMinEscalationFeeLevel.fee(), std::source_location const location=std::source_location::current())
FeatureBitset testableAmendments()
json::Value acctdelete(Account const &account, Account const &dest)
Delete account.
void incLgrSeqForAccDel(jtx::Env &env, jtx::Account const &acc, std::uint32_t margin=0)
std::array< Account, 1+sizeof...(Args)> noripple(Account const &account, Args const &... args)
Designate accounts as no-ripple in Env::fund.
json::Value offer(Account const &account, STAmount const &takerPays, STAmount const &takerGets, std::uint32_t flags)
Create an offer.
std::unique_ptr< Config > envconfig()
creates and initializes a default configuration for jtx::Env
json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
json::Value signers(Account const &account, std::uint32_t quorum, std::vector< Signer > const &v)
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)
constexpr XRPAmount
Convert XRP to drops (integral types).
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool set(T &target, std::string const &name, Section const §ion)
Set a value from a configuration Section If the named value is not found or doesn't parse as a T,...
Issue const & xrpIssue()
Returns an asset specifier that represents XRP.
constexpr FlagValue tfInnerBatchTxn
constexpr std::size_t kMaxBatchSigners
The maximum number of batch signers.
@ SigBad
Signature is bad.
ApplyResult apply(ServiceRegistry ®istry, OpenView &view, STTx const &tx, ApplyFlags flags, beast::Journal journal)
Apply a transaction to an OpenView.
std::string strHex(FwdIt begin, FwdIt end)
std::pair< Validity, std::string > checkValidity(HashRouter &router, STTx const &tx, Rules const &rules)
Checks transaction signature and local checks.
constexpr TenthBips32 percentageToTenthBips(std::uint32_t percentage)
constexpr std::size_t kMaxBatchTxCount
The maximum number of transactions that can be in a batch.
constexpr HashRouterFlags kSfSiggood
UInt256 TxID
A transaction identifier.
XRPAmount toDrops(FeeLevel< T > const &level, XRPAmount baseFee)
TenthBips< std::uint32_t > TenthBips32
TenthBips< std::uint16_t > TenthBips16
std::string to_string(BaseUInt< Bits, Tag > const &a)
bool passesLocalChecks(STTx const &tx, std::string &)
void finishMultiSigningData(AccountID const &signingID, Serializer &s)
MPTID makeMptID(std::uint32_t const sequence, AccountID const &account)
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Buffer sign(PublicKey const &pk, SecretKey const &sk, Slice const &message)
Generate a signature for a message.
TERSubset< CanCvtToTER > TER
std::vector< unsigned char > Blob
Storage for linear binary data.
void serializeBatch(Serializer &msg, AccountID const &outerAccount, std::uint32_t outerSeqValue, std::uint32_t const &flags, std::vector< UInt256 > const &txids)
bool isPseudoTx(STObject const &tx)
Check whether a transaction is a pseudo-transaction.
CanonicalTXSet OrderedTxs
constexpr bool any(HashRouterFlags flags)
static constexpr auto kMinLedgersToComputeSizeLimit
static constexpr auto kRetrySequencePercent
static constexpr auto kMaxLedgerCountsToStore
static constexpr auto kMinimumQueueSize
static constexpr auto kNormalConsensusIncreasePercent
static constexpr auto kLedgersInQueue
static constexpr auto kMinimumTxnInLedgerStandalone
State information when preflighting a tx.
static constexpr auto kTransactionQueue
std::optional< std::string > batchID
Execution context for applying a JSON transaction.
std::shared_ptr< STTx const > stx
Set the sequence number on a JTx.