Skip to content

test: LoanPay regression tests for impaired overdue loans (FN-68) - #7839

Merged
Tapanito merged 3 commits into
tapanito/lending-impairmentfrom
FN-68-loanpay-impaired-late-bypass
Jul 29, 2026
Merged

test: LoanPay regression tests for impaired overdue loans (FN-68)#7839
Tapanito merged 3 commits into
tapanito/lending-impairmentfrom
FN-68-loanpay-impaired-late-bypass

Conversation

@tyalymov

Copy link
Copy Markdown

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 (no
tfLoanLatePayment). The pre-amendment auto-unimpair rewrote
sfNextPaymentDueDate into the future before the late check ran, so the
payment was accepted as on-time (tesSUCCESS), skipping the late fee and
late 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 an
    impaired, overdue loan a plain LoanPay returns tecEXPIRED; the same
    payment with tfLoanLatePayment succeeds, clears impairment, advances the
    schedule, and leaves no residual Vault.LossUnrealized.
  • testImpairedOverdueLoanPayBypassPreAmendment (amendment disabled):
    reproduces the original bypass (tesSUCCESS), proving the amendment is
    what closes it (guards against a vacuous test).

Type of Change

  • Unit tests only (no functional/production change)

@tyalymov
tyalymov requested a review from Tapanito July 21, 2026 14:55

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues.

Review by Claude Sonnet 4.6 · Prompt: V15

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
tyalymov force-pushed the FN-68-loanpay-impaired-late-bypass branch from 726aabe to 846064d Compare July 21, 2026 14:58

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues.

Review by Claude Sonnet 4.6 · Prompt: V15

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues.

Review by Claude Sonnet 4.6 · Prompt: V15

@Tapanito
Tapanito requested a review from a1q123456 July 29, 2026 08:55
@Tapanito
Tapanito changed the base branch from develop to tapanito/lending-impairment July 29, 2026 08:57
@Tapanito
Tapanito requested a review from a team as a code owner July 29, 2026 08:57

@xrplf-ai-reviewer xrplf-ai-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@tyalymov tyalymov added the Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required. label Jul 29, 2026
@Tapanito
Tapanito merged commit 759b470 into tapanito/lending-impairment Jul 29, 2026
62 checks passed
@Tapanito
Tapanito deleted the FN-68-loanpay-impaired-late-bypass branch July 29, 2026 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready to merge *PR author* thinks it's ready to merge. Has passed code review. Perf sign-off may still be required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants