test: Fix LoanBatch broker cover rates and schedule overflow - #7967
Open
Tapanito wants to merge 1 commit into
Open
test: Fix LoanBatch broker cover rates and schedule overflow#7967Tapanito wants to merge 1 commit into
Tapanito wants to merge 1 commit into
Conversation
The LoanBatch manual suite failed in every iteration because testRandomLoan set CoverRateMinimum to zero while leaving CoverRateLiquidation at the 25% default, which LoanBrokerSet preflight rejects with temINVALID (the rates must be both zero or both non-zero). It also randomly generated payment schedules whose final grace period overflows the 32-bit ripple-epoch time horizon, which LoanSet preclaim rejects with tecKILLED. Clamp the payment total so the schedule fits.
Contributor
There was a problem hiding this comment.
The MR correctly fixes the broker cover-rate mismatch and adds a clamp to keep the payment schedule within the 32-bit ripple-epoch horizon. The only concern is the new clamp's division by payInterval, which will crash with a division-by-zero (SIGFPE) if the interval distribution can ever produce 0.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
Fixes the manual
LoanBatchtest suite, which failed in every iteration (20 failures with the default 5 iterations). Both bugs have been present since the lending protocol merged, unnoticed because the suite is manual and not run in CI.Context of Change
LoanBatch_test::testRandomLoanhad two problems:Inconsistent broker cover rates. The broker parameters set
CoverRateMinimumto zero while leavingCoverRateLiquidationat the 25% test default.LoanBrokerSet::preflightrequires the two rates to be both zero or both non-zero, so broker creation failed withtemINVALIDand every subsequent step cascaded (tecNO_ENTRYon cover deposit, missing-object expectation failures). The fix setsCoverRateLiquidationto zero explicitly, matchingLoanArbitrary_test.Payment schedule overflowing the protocol time horizon. The random distributions (payment total up to 10,000, interval up to 30 days) can produce a schedule whose final grace period overflows the 32-bit ripple-epoch timestamp, which
LoanSet::preclaimcorrectly rejects withtecKILLED. The default seed hits this in iteration 5 (4,940 payments at ~21.7-day intervals, about 293 years). The fix clamps the payment total so the schedule stays within 2e9 seconds (~63 years), while still exercising thousand-payment schedules.Type of Change
Test Plan
./xrpld -u LoanBatch: 5 iterations, 446,565 checks, 0 failures (previously 20 failures).