Update ValidVault to allow LoanPay to change LossUnrealized

- Making a payment on an impaired loan will unimpair the loan, which
  changes Vault.LossUnrealized.
- Add a step in unit tests to impair a loan before making a payment, to
  verify, and prevent future similar regressions.
- Resolves regression RIPD-3650
This commit is contained in:
Ed Hennis
2025-10-10 12:54:39 -04:00
parent 8152bcb1f3
commit 66dbc05a9f
2 changed files with 7 additions and 1 deletions

View File

@@ -1856,6 +1856,12 @@ class Loan_test : public beast::unit_test::suite
auto const borrowerBalanceBeforePayment =
env.balance(borrower, broker.asset);
if (canImpairLoan(env, broker, state))
// Making a payment will unimpair the loan
env(manage(lender, loanKeylet.key, tfLoanImpair));
env.close();
// Make the payment
env(pay(borrower, loanKeylet.key, transactionAmount));

View File

@@ -2857,7 +2857,7 @@ ValidVault::finalize(
if (!beforeVault_.empty() &&
afterVault.lossUnrealized != beforeVault_[0].lossUnrealized &&
tx.getTxnType() != ttLOAN_MANAGE)
txnType != ttLOAN_MANAGE && txnType != ttLOAN_PAY)
{
JLOG(j.fatal()) << //
"Invariant failed: vault transaction must not change loss "