Address my review feedback on (#6017)

- Shortcut on issuer match in canTransfer.
- An asset can transfer if either trustline enabled rippling, so both
  must have it disabled for the transfer to fail with terNO_RIPPLE.
- Remove unnecessary asfDefaultRipple sets in unit tests.
- Add a new unit test helper class: testline, and a macro: THISLINE.
  When included as a parameter to Env::operator(), will include the line
  number of the transaction that didn't get the expected result. Works
  similarly to BEAST_EXPECT. I didn't do the same for the file name,
  because that can be deduced from the testcase name.
This commit is contained in:
Ed Hennis
2025-11-18 18:11:16 -05:00
parent d8b944c218
commit fd115cfc13
8 changed files with 123 additions and 50 deletions

View File

@@ -4516,8 +4516,8 @@ protected:
// preclaim
Env env(*this);
env.fund(XRP(1'000), lender, issuer, borrower);
env(trust(lender, IOU(10'000'000)));
env(pay(issuer, lender, IOU(5'000'000)));
env(trust(lender, IOU(10'000'000)), THISLINE);
env(pay(issuer, lender, IOU(5'000'000)), THISLINE);
BrokerInfo brokerInfo{createVaultAndBroker(env, issuer["IOU"], lender)};
auto const loanSetFee = fee(env.current()->fees().base * 2);
@@ -4525,21 +4525,24 @@ protected:
env(set(borrower, brokerInfo.brokerID, debtMaximumRequest),
sig(sfCounterpartySignature, lender),
loanSetFee);
loanSetFee,
THISLINE);
env.close();
std::uint32_t const loanSequence = 1;
auto const loanKeylet = keylet::loan(brokerInfo.brokerID, loanSequence);
env(fset(issuer, asfGlobalFreeze));
env(fset(issuer, asfGlobalFreeze), THISLINE);
env.close();
// preclaim: tecFROZEN
env(pay(borrower, loanKeylet.key, debtMaximumRequest), ter(tecFROZEN));
env(pay(borrower, loanKeylet.key, debtMaximumRequest),
ter(tecFROZEN),
THISLINE);
env.close();
env(fclear(issuer, asfGlobalFreeze));
env(fclear(issuer, asfGlobalFreeze), THISLINE);
env.close();
auto const pseudoBroker = [&]() -> std::optional<Account> {
@@ -4559,37 +4562,51 @@ protected:
// Lender and pseudoaccount must both be frozen
env(trust(
issuer,
lender["IOU"](1'000),
lender,
tfSetFreeze | tfSetDeepFreeze));
issuer,
lender["IOU"](1'000),
lender,
tfSetFreeze | tfSetDeepFreeze),
THISLINE);
env(trust(
issuer,
(*pseudoBroker)["IOU"](1'000),
*pseudoBroker,
tfSetFreeze | tfSetDeepFreeze));
issuer,
(*pseudoBroker)["IOU"](1'000),
*pseudoBroker,
tfSetFreeze | tfSetDeepFreeze),
THISLINE);
env.close();
// preclaim: tecFROZEN due to deep frozen
env(pay(borrower, loanKeylet.key, debtMaximumRequest), ter(tecFROZEN));
env(pay(borrower, loanKeylet.key, debtMaximumRequest),
ter(tecFROZEN),
THISLINE);
env.close();
// Only one needs to be unfrozen
env(trust(
issuer, lender["IOU"](1'000), tfClearFreeze | tfClearDeepFreeze));
issuer,
lender["IOU"](1'000),
tfClearFreeze | tfClearDeepFreeze),
THISLINE);
env.close();
// The payment is late by this point
env(pay(borrower, loanKeylet.key, debtMaximumRequest), ter(tecEXPIRED));
env(pay(borrower, loanKeylet.key, debtMaximumRequest),
ter(tecEXPIRED),
THISLINE);
env.close();
env(pay(
borrower, loanKeylet.key, debtMaximumRequest, tfLoanLatePayment));
env(pay(borrower,
loanKeylet.key,
debtMaximumRequest,
tfLoanLatePayment),
THISLINE);
env.close();
// preclaim: tecKILLED
// note that tecKILLED in loanMakePayment()
// doesn't happen because of the preclaim check.
env(pay(borrower, loanKeylet.key, debtMaximumRequest), ter(tecKILLED));
env(pay(borrower, loanKeylet.key, debtMaximumRequest),
ter(tecKILLED),
THISLINE);
}
void