Gating impair on `fixCleanup3_4_0` switched the "reject not-yet-late
impair with tecTOO_SOON" behaviour from an amendment excluded by
`LoanTestBase::all_` to one that is included. Every shared helper that
called `manage(tfLoanImpair)` immediately after loan creation started
returning tecTOO_SOON, cascading into ~7.8k assertion failures across
LoanLifecycle, LoanSet, LoanMisc, LoanPay, LoanRounding, LoanInvariants
and LoanCoverFreezeAuth.
Fixes:
- Add `advancePastDueDate(env, loanKeylet)` helper to LoanTestBase.h.
Advances the ledger past `sfNextPaymentDueDate` under the fix and is a
no-op otherwise.
- `defaultImmediately`: advance past due date before impair and gate the
legacy `state.nextPaymentDate = env.now()` mutation on the fix state
(the fix preserves `sfNextPaymentDueDate`).
- `combineAllPayments` payment loop: only impair when the loan is
actually late so periodic-payment iterations are not perturbed.
- `lifecycle` inline impair/unimpair sub-block: keep the pre-amendment
`tesSUCCESS`/`tecLIMIT_EXCEEDED` path when the fix is off; assert the
new `tecTOO_SOON` (impair) + `tecNO_PERMISSION` (unimpair-on-unimpaired)
contract when the fix is on. Advancing here would push the loan into a
late state and break the downstream `toEndOfLife` payment flows with
`tecEXPIRED`. The tesSUCCESS impair branch is separately covered by
LoanSecurity_test.cpp and LoanCashBasis_test.cpp under the fix.
- LoanCoverFreezeAuth_test.cpp `testWithdrawReflectsUnrealizedLoss`:
advance past due date before the direct impair call.
- LoanCashBasis_test.cpp: drop the now-duplicated local
`advancePastDueDate` lambda in favour of the base helper.
Switches the impair/unimpair behaviour change (reject non-late impair
with tecTOO_SOON; stop rewriting sfNextPaymentDueDate on impair/unimpair)
from featureLendingProtocolV1_1 to fixCleanup3_4_0, along with the
associated tests.
Conflict resolutions:
- include/xrpl/ledger/helpers/LendingHelpers.h,
src/libxrpl/ledger/helpers/LendingHelpers.cpp: Keep both branches' additions.
Preserve isPaymentLate() from lending-impairment alongside develop's new
cash-basis accounting helpers (accrual/cash_basis dispatchers).
- src/libxrpl/tx/transactors/lending/LoanManage.cpp: Rerere-resolved to
combine lending-impairment's featureLendingProtocolV1_1 gating with
develop's refactor from owedToVault() to loanVaultExposure().
- src/test/app/Loan_test.cpp (deleted upstream, modified locally): Accept
the deletion and migrate our four impairment/LoanPay regression tests
into src/test/app/lending/LoanSecurity_test.cpp:
* testImpairmentPaymentDateUnchanged
* testImpairmentPaymentDatePreAmendment
* testImpairedOverdueLoanPayRequiresLateFlag
* testImpairedOverdueLoanPayBypassPreAmendment
- src/test/app/lending/LoanCashBasis_test.cpp: Adjust the impair calls in
runImpairUnimpair, runDefault, and testLegacyVaultKeepsAccrualAfterAmendmentEnabled
to advance the clock past sfNextPaymentDueDate before impairing, since
featureLendingProtocolV1_1 now rejects impairment on non-late loans.