test: LoanPay regression tests for impaired overdue loans (FN-68) - #7839
Merged
Tapanito merged 3 commits intoJul 29, 2026
Merged
Conversation
Cover the LoanPay side of the impairment fix from FN-9 (#6557): - with featureLendingProtocolV1_1, a plain LoanPay on an impaired, overdue loan is rejected with tecEXPIRED and only tfLoanLatePayment is accepted, clearing impairment with no residual vault LossUnrealized; - without the amendment, the original bypass reproduces (tesSUCCESS), proving the amendment is what closes it.
tyalymov
force-pushed
the
FN-68-loanpay-impaired-late-bypass
branch
from
July 21, 2026 14:58
726aabe to
846064d
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Tapanito
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
High Level Overview of Change
Adds regression tests covering the LoanPay
side of the impairment fix in this branch (FN-9 / #6557). Stacked on
tapanito/lending-impairment; intended to land with that PR.Context of Change
FN-68 is a bug-bounty report: a borrower could bypass late-payment charges
by paying an impaired, overdue loan with a plain
LoanPay(notfLoanLatePayment). The pre-amendment auto-unimpair rewrotesfNextPaymentDueDateinto the future before the late check ran, so thepayment was accepted as on-time (
tesSUCCESS), skipping the late fee andlate interest — and the late path was itself unusable (
tecTOO_SOON).FN-9 already fixes the root cause under
featureLendingProtocolV1_1(impair/unimpair no longer move the due date; impairment is only allowed
once the payment is late). These tests assert that fix from the
borrower-facing LoanPay angle, which the existing FN-9 tests did not cover.
Changes
Two cases in
src/test/app/Loan_test.cpp:testImpairedOverdueLoanPayRequiresLateFlag(amendment enabled): on animpaired, overdue loan a plain
LoanPayreturnstecEXPIRED; the samepayment with
tfLoanLatePaymentsucceeds, clears impairment, advances theschedule, and leaves no residual
Vault.LossUnrealized.testImpairedOverdueLoanPayBypassPreAmendment(amendment disabled):reproduces the original bypass (
tesSUCCESS), proving the amendment iswhat closes it (guards against a vacuous test).
Type of Change