xrpld
Loading...
Searching...
No Matches
LoanValidation_test.cpp
1#include <test/app/lending/LoanTestBase.h>
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/envconfig.h>
7#include <test/jtx/fee.h>
8#include <test/jtx/flags.h>
9#include <test/jtx/mpt.h>
10#include <test/jtx/pay.h>
11#include <test/jtx/sponsor.h>
12#include <test/jtx/ter.h>
13#include <test/jtx/trust.h>
14#include <test/jtx/txflags.h>
15#include <test/jtx/vault.h>
16
17#include <xrpl/basics/Number.h>
18#include <xrpl/basics/base_uint.h>
19#include <xrpl/basics/strHex.h>
20#include <xrpl/beast/unit_test/suite.h>
21#include <xrpl/beast/utility/Journal.h>
22#include <xrpl/beast/utility/Zero.h>
23#include <xrpl/json/json_value.h>
24#include <xrpl/json/to_string.h>
25#include <xrpl/ledger/helpers/AccountRootHelpers.h>
26#include <xrpl/protocol/Feature.h>
27#include <xrpl/protocol/Indexes.h>
28#include <xrpl/protocol/Issue.h>
29#include <xrpl/protocol/Protocol.h>
30#include <xrpl/protocol/SField.h>
31#include <xrpl/protocol/STTx.h>
32#include <xrpl/protocol/SeqProxy.h>
33#include <xrpl/protocol/TER.h>
34#include <xrpl/protocol/TxFlags.h>
35#include <xrpl/protocol/jss.h>
36#include <xrpl/tx/transactors/lending/LoanSet.h>
37
38#include <cstdint>
39#include <optional>
40
41namespace xrpl::test {
42
44{
45private:
46 void
48 {
49 testcase("Disabled");
50 // Lending Protocol depends on Single Asset Vault (SAV). Test
51 // combinations of the two amendments.
52 // Single Asset Vault depends on MPTokensV1, but don't test every combo
53 // of that.
54 using namespace jtx;
55 auto const failAll = [this](FeatureBitset features) {
56 Env env(*this, features);
57
58 Account const alice{"alice"};
59 Account const bob{"bob"};
60 env.fund(XRP(10000), alice, bob);
61
62 auto const keylet = keylet::loanBroker(alice, SeqProxy::rawSequence(env.seq(alice)));
63
64 using namespace std::chrono_literals;
65 using namespace loan;
66
67 // counter party signature is optional on LoanSet. Confirm that by
68 // sending transaction without one.
69 auto setTx = env.jt(set(alice, keylet.key, Number(10000)), Ter(temDISABLED));
70 env(setTx);
71
72 // All loan transactions are disabled.
73 // 1. LoanSet
74 setTx = env.jt(setTx, Sig(sfCounterpartySignature, bob), Ter(temDISABLED));
75 env(setTx);
76 // Actual sequence will be based off the loan broker, but we
77 // obviously don't have one of those if the amendment is disabled
78 auto const loanKeylet = keylet::loan(keylet.key, SeqProxy::rawSequence(env.seq(alice)));
79 // Other Loan transactions are disabled, too.
80 // 2. LoanDelete
81 env(del(alice, loanKeylet.key), Ter(temDISABLED));
82 // 3. LoanManage
83 env(manage(alice, loanKeylet.key, tfLoanImpair), Ter(temDISABLED));
84 // 4. LoanPay
85 env(pay(alice, loanKeylet.key, XRP(500)), Ter(temDISABLED));
86 };
87 failAll(all_ - featureMPTokensV1);
88 failAll(all_ - featureSingleAssetVault - featureLendingProtocol);
89 failAll(all_ - featureSingleAssetVault);
90 failAll(all_ - featureLendingProtocol);
91 }
92
93 void
95 {
97 std::string("Invalid LoanSet (") +
98 (vaultKind == VaultKind::OpenEnded ? "open-ended" : "closed-ended") + " vault)");
99 using namespace jtx;
100 using namespace loan;
101 Account const lender{"lender"};
102 Account const issuer{"issuer"};
103 Account const borrower{"borrower"};
104 Account const sponsor{"sponsor"};
105 auto const iou = issuer["IOU"];
106
107 auto const testWrapper = [&](auto&& test) {
108 Env env(*this);
109 env.fund(XRP(1'000), lender, issuer, borrower, sponsor);
110 env(trust(lender, iou(10'000'000)));
111 env(pay(issuer, lender, iou(5'000'000)));
112 BrokerInfo const brokerInfo{
113 createVaultAndBroker(env, issuer["IOU"], lender, {.vaultKind = vaultKind}),
114 };
115
116 auto const loanSetFee = Fee(env.current()->fees().base * 2);
117 Number const debtMaximumRequest = brokerInfo.asset(1'000).value();
118 test(env, brokerInfo, loanSetFee, debtMaximumRequest);
119 };
120
121 // preflight:
122 testWrapper([&](Env& env,
123 BrokerInfo const& brokerInfo,
124 jtx::Fee const& loanSetFee,
125 Number const& debtMaximumRequest) {
126 for (auto const sponsorFlags : {spfSponsorReserve, spfSponsorReserve | spfSponsorFee})
127 {
128 env(set(borrower, brokerInfo.brokerID, debtMaximumRequest),
129 sponsor::As(sponsor, sponsorFlags),
130 Sig(sfCounterpartySignature, lender),
131 loanSetFee,
133 }
134
135 // first temBAD_SIGNER: TODO
136 // invalid grace period
137 {
138 // zero grace period
139 env(set(borrower, brokerInfo.brokerID, debtMaximumRequest),
140 Sig(sfCounterpartySignature, lender),
141 kGracePeriod(0),
142 loanSetFee,
143 Ter(temINVALID));
144
145 // grace period less than default minimum
146 env(set(borrower, brokerInfo.brokerID, debtMaximumRequest),
147 Sig(sfCounterpartySignature, lender),
148 kGracePeriod(LoanSet::kDefaultGracePeriod - 1),
149 loanSetFee,
150 Ter(temINVALID));
151
152 // grace period greater than payment interval
153 env(set(borrower, brokerInfo.brokerID, debtMaximumRequest),
154 Sig(sfCounterpartySignature, lender),
155 kPaymentInterval(120),
156 kGracePeriod(121),
157 loanSetFee,
158 Ter(temINVALID));
159 }
160 // empty/zero broker ID
161 {
162 auto jv = set(borrower, UInt256{}, debtMaximumRequest);
163
164 auto const testZeroBrokerID = [&](std::string const& id, std::uint32_t flags = 0) {
165 // empty broker ID
166 jv[sfLoanBrokerID] = id;
167 env(jv,
168 Sig(sfCounterpartySignature, lender),
169 loanSetFee,
170 Txflags(flags),
171 Ter(temINVALID));
172 };
173 // empty broker ID
174 testZeroBrokerID(std::string(""));
175 // zero broker ID
176 // needs a flag to distinguish the parsed STTx from the prior
177 // test
178 testZeroBrokerID(to_string(UInt256{}), tfFullyCanonicalSig);
179 }
180
181 // preflightCheckSigningKey() failure:
182 // can it happen? the signature is checked before transactor
183 // executes
184
185 JTx const tx = env.jt(
186 set(borrower, brokerInfo.brokerID, debtMaximumRequest),
187 Sig(sfCounterpartySignature, lender),
188 loanSetFee);
189 STTx local = *tx.stx;
190 auto counterpartySig = local.getFieldObject(sfCounterpartySignature);
191 auto badPubKey = counterpartySig.getFieldVL(sfSigningPubKey);
192 badPubKey[20] ^= 0xAA;
193 counterpartySig.setFieldVL(sfSigningPubKey, badPubKey);
194 local.setFieldObject(sfCounterpartySignature, counterpartySig);
195 json::Value jvResult;
196 jvResult[jss::tx_blob] = strHex(local.getSerializer().slice());
197 auto res = env.rpc("json", "submit", to_string(jvResult))["result"];
198 BEAST_EXPECT(
199 res[jss::error] == "invalidTransaction" && !res.isMember(jss::error_code) &&
200 res[jss::error_message].isNull() &&
201 res[jss::error_exception] ==
202 "fails local checks: Counterparty: Invalid signature.");
203 });
204
205 // preclaim:
206 testWrapper([&](Env& env,
207 BrokerInfo const& brokerInfo,
208 jtx::Fee const& loanSetFee,
209 Number const& debtMaximumRequest) {
210 // canAddHoldingFailure (IOU only, if MPT doesn't have
211 // MPTCanTransfer set, then can't create Vault/LoanBroker,
212 // and LoanSet will fail with different error
213 env(fclear(issuer, asfDefaultRipple));
214 env.close();
215 env(set(borrower, brokerInfo.brokerID, debtMaximumRequest),
216 Sig(sfCounterpartySignature, lender),
217 loanSetFee,
219 });
220
221 // doApply:
222 testWrapper([&](Env& env,
223 BrokerInfo const& brokerInfo,
224 jtx::Fee const& loanSetFee,
225 Number const& debtMaximumRequest) {
226 auto const amt =
227 env.balance(borrower) - accountReserve(*env.current(), borrower.id(), env.journal);
228 env(pay(borrower, issuer, amt));
229
230 // tecINSUFFICIENT_RESERVE
231 env(set(borrower, brokerInfo.brokerID, debtMaximumRequest),
232 Sig(sfCounterpartySignature, lender),
233 loanSetFee,
235
236 // addEmptyHolding failure
237 env(pay(issuer, borrower, amt));
238 env(fset(issuer, asfGlobalFreeze));
239 env.close();
240
241 env(set(borrower, brokerInfo.brokerID, debtMaximumRequest),
242 Sig(sfCounterpartySignature, lender),
243 loanSetFee,
244 Ter(tecFROZEN));
245 });
246 }
247
248 void
250 {
251 testcase("Invalid LoanDelete");
252 using namespace jtx;
253 using namespace loan;
254
255 // preflight: temINVALID, LoanID == zero
256 {
257 Account const alice{"alice"};
258 Env env(*this);
259 env.fund(XRP(1'000), alice);
260 env.close();
261 env(del(alice, beast::kZero), Ter(temINVALID));
262 }
263 }
264
265 void
267 {
268 testcase("Invalid LoanManage");
269 using namespace jtx;
270 using namespace loan;
271
272 // preflight: temINVALID, LoanID == zero
273 {
274 Account const alice{"alice"};
275 Env env(*this);
276 env.fund(XRP(1'000), alice);
277 env.close();
278 env(manage(alice, beast::kZero, tfLoanDefault), Ter(temINVALID));
279 }
280 }
281
282 void
284 {
285 testcase("Invalid LoanPay");
286 using namespace jtx;
287 using namespace loan;
288 Account const lender{"lender"};
289 Account const issuer{"issuer"};
290 Account const borrower{"borrower"};
291 auto const iou = issuer["IOU"];
292
293 // preclaim
294 Env env(*this);
295 env.fund(XRP(1'000), lender, issuer, borrower);
296 env(trust(lender, iou(10'000'000)));
297 env(pay(issuer, lender, iou(5'000'000)));
298 BrokerInfo brokerInfo{createVaultAndBroker(env, issuer["IOU"], lender)};
299
300 auto const loanSetFee = Fee(env.current()->fees().base * 2);
301 STAmount const debtMaximumRequest = brokerInfo.asset(1'000).value();
302
303 env(set(borrower, brokerInfo.brokerID, debtMaximumRequest),
304 Sig(sfCounterpartySignature, lender),
305 loanSetFee);
306
307 env.close();
308
309 std::uint32_t const loanSequence = 1;
310 auto const loanKeylet =
311 keylet::loan(brokerInfo.brokerID, SeqProxy::rawSequence(loanSequence));
312
313 env(fset(issuer, asfGlobalFreeze));
314 env.close();
315
316 // preclaim: tecFROZEN
317 env(pay(borrower, loanKeylet.key, debtMaximumRequest), Ter(tecFROZEN));
318 env.close();
319
320 env(fclear(issuer, asfGlobalFreeze));
321 env.close();
322
323 auto const pseudoBroker = [&] -> std::optional<Account> {
324 if (auto const brokerSle = env.le(keylet::loanBroker(brokerInfo.brokerID));
325 BEAST_EXPECT(brokerSle))
326 {
327 return Account{"pseudo", brokerSle->at(sfAccount)};
328 }
329
330 return std::nullopt;
331 }();
332 if (!pseudoBroker)
333 return;
334
335 // Lender and pseudoaccount must both be frozen
336 env(trust(issuer, lender["IOU"](1'000), lender, tfSetFreeze | tfSetDeepFreeze));
337 env(trust(
338 issuer, (*pseudoBroker)["IOU"](1'000), *pseudoBroker, tfSetFreeze | tfSetDeepFreeze));
339 env.close();
340
341 // preclaim: tecFROZEN due to deep frozen
342 env(pay(borrower, loanKeylet.key, debtMaximumRequest), Ter(tecFROZEN));
343 env.close();
344
345 // Only one needs to be unfrozen
346 env(trust(issuer, lender["IOU"](1'000), tfClearFreeze | tfClearDeepFreeze));
347 env.close();
348
349 // The payment is late by this point. With fixCleanup3_4_0,
350 // isPaymentLate() uses a strict (Exclusive) comparison, so advance
351 // one more ledger close to be sure the due date instant itself has
352 // passed, not merely reached.
353 env.close();
354
355 env(pay(borrower, loanKeylet.key, debtMaximumRequest), Ter(tecEXPIRED));
356 env.close();
357 env(pay(borrower, loanKeylet.key, debtMaximumRequest, tfLoanLatePayment));
358 env.close();
359
360 // preclaim: tecKILLED
361 // note that tecKILLED in loanMakePayment()
362 // doesn't happen because of the preclaim check.
363 env(pay(borrower, loanKeylet.key, debtMaximumRequest), Ter(tecKILLED));
364 }
365
366 void
368 {
369 testcase("Require Auth - Implicit Pseudo-account authorization");
370 using namespace jtx;
371 using namespace loan;
372 Account const lender{"lender"};
373 Account const issuer{"issuer"};
374 Account const borrower{"borrower"};
375 Env env(*this);
376
377 env.fund(XRP(100'000), issuer, lender, borrower);
378 env.close();
379
380 auto asset = MPTTester({
381 .env = env,
382 .issuer = issuer,
383 .holders = {lender, borrower},
384 .flags = kMptDexFlags | tfMPTRequireAuth | tfMPTCanClawback | tfMPTCanLock,
385 .authHolder = true,
386 });
387
388 env(pay(issuer, lender, asset(5'000'000)));
389 BrokerInfo brokerInfo{createVaultAndBroker(env, asset, lender)};
390
391 auto const loanSetFee = Fee(env.current()->fees().base * 2);
392 STAmount const debtMaximumRequest = brokerInfo.asset(1'000).value();
393
394 auto const forUnauthAuth = [&](auto&& doTx) {
395 for (auto const flag : {tfMPTUnauthorize, 0u})
396 {
397 asset.authorize({.account = issuer, .holder = borrower, .flags = flag});
398 env.close();
399 doTx(flag == 0);
400 env.close();
401 }
402 };
403
404 // Can't create a loan if the borrower is not authorized
405 forUnauthAuth([&](bool authorized) {
406 auto const err = !authorized ? Ter(tecNO_AUTH) : Ter(tesSUCCESS);
407 env(set(borrower, brokerInfo.brokerID, debtMaximumRequest),
408 Sig(sfCounterpartySignature, lender),
409 loanSetFee,
410 err);
411 });
412
413 static constexpr std::uint32_t kLoanSequence = 1;
414 auto const loanKeylet =
415 keylet::loan(brokerInfo.brokerID, SeqProxy::rawSequence(kLoanSequence));
416
417 // Can't loan pay if the borrower is not authorized
418 forUnauthAuth([&](bool authorized) {
419 auto const err = !authorized ? Ter(tecNO_AUTH) : Ter(tesSUCCESS);
420 env(pay(borrower, loanKeylet.key, debtMaximumRequest), err);
421 });
422 }
423
424 void
426 {
427 testcase("RIPD-4125 - overpayment");
428
429 using namespace jtx;
430
431 Account const issuer("issuer");
432 Account const lender("lender");
433 Account const borrower("borrower");
434
435 BrokerParameters const brokerParams{
436 .vaultDeposit = 100'000,
437 .debtMax = 0,
438 .coverRateMin = TenthBips32{0},
439 .managementFeeRate = TenthBips16{0},
440 .coverRateLiquidation = TenthBips32{0},
441 };
442 LoanParameters const loanParams{
443 .account = lender,
444 .counter = borrower,
445 .principalRequest = Number{200000, -6},
446 .interest = TenthBips32{50000},
447 .payTotal = 3,
448 .payInterval = 200,
449 .gracePd = 60,
450 .flags = tfLoanOverpayment,
451 };
452
453 auto const assetType = AssetType::XRP;
454
455 Env env(*this, makeConfig(), all_, nullptr, beast::Severity::Warning);
456
457 auto loanResult =
458 createLoan(env, assetType, brokerParams, loanParams, issuer, lender, borrower);
459
460 if (BEAST_EXPECT(loanResult); !loanResult.has_value())
461 return;
462
463 auto const broker = std::get<BrokerInfo>(*loanResult);
464 auto const loanKeylet = std::get<Keylet>(*loanResult);
465 auto const pseudoAcct = std::get<Account>(*loanResult);
466
467 VerifyLoanStatus const verifyLoanStatus(env, broker, pseudoAcct, loanKeylet);
468
469 auto const state = getCurrentState(env, broker, loanKeylet);
470
471 env(loan::pay(
472 borrower,
473 loanKeylet.key,
474 STAmount{broker.asset, state.periodicPayment * 3 / 2 + 1},
475 tfLoanOverpayment));
476 env.close();
477
478 PaymentParameters const paymentParams{
479 .showStepBalances = false,
480 .validateBalances = true,
481 };
482
484 env,
485 broker,
486 loanParams,
487 loanKeylet,
488 verifyLoanStatus,
489 issuer,
490 lender,
491 borrower,
492 paymentParams);
493 }
494
495 void
497 {
498 // From FIND-003
499 testcase << "Wrong Max Debt Behavior";
500
501 using namespace jtx;
502 using namespace std::chrono_literals;
503 Env env(*this, features);
504
505 Account const issuer{"issuer"};
506 Account const lender{"lender"};
507
508 BrokerParameters const brokerParams{.debtMax = 0};
509 env.fund(XRP(brokerParams.vaultDeposit * 100), issuer, noripple(lender));
510 env.close();
511
512 PrettyAsset const xrpAsset{xrpIssue(), 1'000'000};
513
514 BrokerInfo const broker{createVaultAndBroker(env, xrpAsset, lender, brokerParams)};
515
516 if (auto const brokerSle = env.le(keylet::loanBroker(broker.brokerID));
517 BEAST_EXPECT(brokerSle))
518 {
519 BEAST_EXPECT(brokerSle->at(sfDebtMaximum) == 0);
520 }
521
522 using namespace loan;
523
524 auto const loanSetFee = Fee(env.current()->fees().base * 2);
525 Number const principalRequest{1, 3};
526
527 // The lender is both the borrower and the counterparty here, but the
528 // two roles sign different bytes, so each signature must be made for
529 // the field it goes into.
530 auto const createJson = env.json(
531 set(lender, broker.brokerID, principalRequest),
532 Sig(sfCounterpartySignature, lender),
533 Fee(loanSetFee));
534 env(createJson);
535
536 env.close();
537 }
538
539 // Under featureLendingProtocolV1_1 LoanBrokerSet::preclaim rejects
540 // attaching a broker to an open-ended vault. VaultCreate itself is
541 // not gated by the amendment, so the same open-ended vault can be
542 // built under either feature set; only the broker create is
543 // amendment-sensitive. Cover both branches: LP V1.1 disabled lets
544 // the broker create succeed, LP V1.1 enabled rejects it. The gate
545 // only fires on the create path; existing brokers keep working.
546 void
548 {
549 testcase("LoanBrokerSet requires closed-ended vault under LP V1.1");
550 using namespace jtx;
551
552 Account const owner{"lp11_owner"};
553
554 auto const build = [&](FeatureBitset features,
555 TER expected,
556 std::optional<TER> updateExpected = std::nullopt) {
557 Env env(*this, features);
558 env.fund(XRP(1'000), owner);
559 env.close();
560
561 Vault const vault{env};
562 auto [tx, vaultKeylet] = vault.create({.owner = owner, .asset = xrpIssue()});
563 env(tx);
564 env.close();
565 env(vault.deposit({.depositor = owner, .id = vaultKeylet.key, .amount = XRP(100)}));
566 env.close();
567
568 auto const brokerKeylet =
569 keylet::loanBroker(owner.id(), SeqProxy::rawSequence(env.seq(owner)));
570 env(loan_broker::set(owner, vaultKeylet.key), Ter(expected));
571 env.close();
572
573 // The create-path gate is the only new check; updates to an
574 // existing broker on the same open-ended vault are not
575 // affected. Only exercise the update path when the create
576 // succeeded (so there is a broker to update).
577 if (updateExpected && expected == tesSUCCESS)
578 {
579 env(loan_broker::set(owner, vaultKeylet.key),
580 loan_broker::kLoanBrokerId(brokerKeylet.key),
581 loan_broker::kDebtMaximum(XRP(1'000).value()),
582 Ter(*updateExpected));
583 env.close();
584 }
585 };
586
587 // Baseline: LP V1.1 disabled -> open-ended vault + broker succeeds.
588 build(all_, tesSUCCESS, tesSUCCESS);
589
590 // LP V1.1 enabled -> open-ended vault + broker rejected on create.
591 build(all_ | featureLendingProtocolV1_1, tecNO_PERMISSION);
592 }
593
594 void
607
608 // Tests run under each entry in amendmentCombinations().
609 void
614
615public:
616 void
617 run() override
618 {
620 for (auto const& features : jtx::amendmentCombinations(
621 {fixCleanup3_1_3, fixCleanup3_2_0, featureMPTokensV2}, all_))
622 runAmendmentSensitive(features);
623 }
624};
625
626BEAST_DEFINE_TESTSUITE(LoanValidation, tx, xrpl);
627
628} // namespace xrpl::test
TestcaseT testcase
Memberspace for declaring test cases.
Definition suite.h:155
Represents a JSON value.
Definition json_value.h:121
static constexpr std::uint32_t kDefaultGracePeriod
Number is a floating point type that can represent a wide range of values.
Definition Number.h:351
Blob getFieldVL(SField const &field) const
Definition STObject.cpp:649
Serializer getSerializer() const
Definition STObject.h:1002
void setFieldObject(SField const &field, STObject const &v)
Definition STObject.cpp:839
STObject getFieldObject(SField const &field) const
Definition STObject.cpp:678
static constexpr SeqProxy rawSequence(std::uint32_t v)
Factory function to return a sequence-based SeqProxy.
Definition SeqProxy.h:62
Slice slice() const noexcept
Definition Serializer.h:141
Shared base for the Loan*_test family under src/test/app/lending/.
FeatureBitset const all_
BrokerInfo createVaultAndBroker(jtx::Env &env, jtx::PrettyAsset const &asset, jtx::Account const &lender, BrokerParameters const &params=BrokerParameters::defaults())
LoanState getCurrentState(jtx::Env const &env, BrokerInfo const &broker, Keylet const &loanKeylet)
Get the state without checking anything.
void makeLoanPayments(jtx::Env &env, BrokerInfo const &broker, LoanParameters const &loanParams, Keylet const &loanKeylet, VerifyLoanStatus const &verifyLoanStatus, jtx::Account const &issuer, jtx::Account const &lender, jtx::Account const &borrower, PaymentParameters const &paymentParams=PaymentParameters::defaults())
std::optional< std::tuple< BrokerInfo, Keylet, jtx::Account > > createLoan(jtx::Env &env, AssetType assetType, BrokerParameters const &brokerParams, LoanParameters const &loanParams, jtx::Account const &issuer, jtx::Account const &lender, jtx::Account const &borrower)
void runAmendmentSensitive(FeatureBitset features)
void run() override
Runs the suite.
void testWrongMaxDebtBehavior(FeatureBitset features)
void testInvalidLoanSet(VaultKind vaultKind)
Immutable cryptographic account descriptor.
Definition jtx/Account.h:21
AccountID id() const
Returns the Account ID.
A transaction testing environment.
Definition Env.h:161
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
Definition Env.cpp:133
json::Value json(JsonValue &&jv, FN const &... fN)
Create JSON from parameters.
Definition Env.h:752
SLE::const_pointer le(Account const &account) const
Return an account root.
Definition Env.cpp:311
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Definition Env.cpp:323
std::uint32_t seq(Account const &account) const
Returns the next sequence number on account.
Definition Env.cpp:302
json::Value rpc(unsigned apiVersion, std::unordered_map< std::string, std::string > const &headers, std::string const &cmd, Args &&... args)
Execute an RPC command.
Definition Env.h:1058
JTx jt(JsonValue &&jv, FN const &... fN)
Create a JTx from parameters.
Definition Env.h:723
PrettyAmount balance(Account const &account) const
Returns the XRP balance on an account.
Definition Env.cpp:201
beast::Journal const journal
Definition Env.h:204
std::shared_ptr< OpenView const > current() const
Returns the current ledger.
Definition Env.h:377
Set the fee on a JTx.
Definition fee.h:20
Test helper for creating, mutating, and asserting MPT and confidential MPT ledger state.
Definition mpt.h:512
Set the regular signature on a JTx.
Definition sig.h:19
Set the expected result code for a JTx The test will fail if the code doesn't match.
Definition ter.h:18
Set the flags on a JTx.
Definition txflags.h:14
constexpr Zero kZero
Definition Zero.h:30
Keylet computation functions.
Definition Indexes.h:39
Keylet loanBroker(AccountID const &owner, SeqProxy const &seq) noexcept
Definition Indexes.cpp:571
Keylet loan(UInt256 const &loanBrokerID, SeqProxy const &loanSeq) noexcept
Definition Indexes.cpp:577
json::Value set(AccountID const &account, UInt256 const &vaultId, uint32_t flags)
json::Value pay(AccountID const &account, UInt256 const &loanID, STAmount const &amount, std::uint32_t flags)
auto const kMptDexFlags
Definition mpt.h:47
json::Value pay(AccountID const &account, AccountID const &to, AnyAmount amount)
Create a payment.
Definition pay.cpp:14
std::vector< FeatureBitset > amendmentCombinations(std::initializer_list< UInt256 > features, FeatureBitset seed)
Returns all 2^N permutations of a seed FeatureBitset with each subset of the given features excluded.
Definition Env.h:123
XrpT const XRP
Converts to XRP Issue or STAmount.
Definition amount.cpp:92
std::unique_ptr< Config > makeConfig(std::map< std::string, std::string > extraTxQ={}, std::map< std::string, std::string > extraVoting={})
json::Value fclear(Account const &account, std::uint32_t off)
Remove account flag.
Definition flags.h:110
std::array< Account, 1+sizeof...(Args)> noripple(Account const &account, Args const &... args)
Designate accounts as no-ripple in Env::fund.
Definition Env.h:86
json::Value trust(Account const &account, STAmount const &amount, std::uint32_t flags)
Modify a trust line.
Definition trust.cpp:18
json::Value fset(Account const &account, std::uint32_t on, std::uint32_t off=0)
Add and/or remove flag.
Definition flags.cpp:15
BEAST_DEFINE_TESTSUITE(AMMClawback, app, xrpl)
static STAmount accountReserve(jtx::Env const &env, std::uint32_t count=1)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
constexpr FlagValue spfSponsorFee
Definition TxFlags.h:467
@ terNO_RIPPLE
Definition TER.h:226
bool set(T &target, std::string const &name, Section const &section)
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.
Definition Issue.h:108
std::string strHex(FwdIt begin, FwdIt end)
Definition strHex.h:13
static bool authorized(Port const &port, std::map< std::string, std::string > const &h)
TenthBips< std::uint32_t > TenthBips32
Definition Units.h:454
TenthBips< std::uint16_t > TenthBips16
Definition Units.h:453
VaultKind
Vault kind.
Definition Protocol.h:358
std::string to_string(BaseUInt< Bits, Tag > const &a)
Definition base_uint.h:658
BaseUInt< 256 > UInt256
Definition base_uint.h:581
@ temINVALID
Definition TER.h:98
@ temINVALID_FLAG
Definition TER.h:99
@ temDISABLED
Definition TER.h:102
TERSubset< CanCvtToTER > TER
Definition TER.h:657
@ tecNO_AUTH
Definition TER.h:311
@ tecFROZEN
Definition TER.h:314
@ tecEXPIRED
Definition TER.h:325
@ tecINSUFFICIENT_RESERVE
Definition TER.h:318
@ tecKILLED
Definition TER.h:327
@ tecNO_PERMISSION
Definition TER.h:316
constexpr FlagValue spfSponsorReserve
Definition TxFlags.h:468
@ tesSUCCESS
Definition TER.h:253
constexpr FlagValue tfFullyCanonicalSig
Definition TxFlags.h:43
Helper class to compare the expected state of a loan and loan broker against the data in the ledger.
Execution context for applying a JSON transaction.
Definition JTx.h:27
std::shared_ptr< STTx const > stx
Definition JTx.h:37