mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
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:
@@ -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));
|
||||
|
||||
|
||||
@@ -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 "
|
||||
|
||||
Reference in New Issue
Block a user