fix: Correct sign-check wording in lending protocol messages - #7913
Merged
Conversation
Several vault invariant log messages and one LoanPay assert said a value "must be positive" while the check only rejects negative values (zero is valid). Reword to "must not be negative" / "non-negative" to match the actual check. Log/assert text only; no behaviour change.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR corrects misleading diagnostic wording in the lending protocol’s vault/loan invariant messages so the text matches the actual non-negativity checks (i.e., values may be zero). This is a log/assert message update only and does not change transaction behavior or consensus logic.
Changes:
- Reworded VaultInvariant invariant-failure log messages from “must be positive” to “must not be negative”.
- Reworded a
LoanPayinternal assert description from “positive … balances” to “non-negative … balances”. - Updated invariant unit test expectations to match the new wording.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/test/app/Invariants_test.cpp | Updates expected invariant-failure strings to match the corrected non-negativity wording. |
| src/libxrpl/tx/transactors/lending/LoanPay.cpp | Adjusts assert description text to “non-negative” to align with >= 0 check. |
| src/libxrpl/tx/invariants/VaultInvariant.cpp | Updates invariant failure log messages to reflect non-negativity (< 0 rejection) rather than strict positivity. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Correct misleading sign-check wording in lending-protocol diagnostic messages. Several
vault invariant log messages and one
LoanPayassert stated that a value "must bepositive" while the corresponding check only rejects negative values (zero is a valid
state). They now say "must not be negative" / "non-negative" to match the actual check.
This is diagnostic text only — there is no behavioural or consensus change.
Context of Change
Following review discussion on #7863: the vault/loan invariants use
< 0(or>= 0)comparisons, i.e. they enforce non-negativity, but several messages read "must be
positive", which implies
> 0. Zero is legitimate (e.g. an empty vault hasassetsAvailable == 0,assetsTotal == 0;assetsMaximum == 0means "no maximum";a vault with no impaired loans has
lossUnrealized == 0), so the wording was misleadingwhen diagnosing invariant failures.
Reworded to match the checks:
VaultInvariant.cpp— "assets available / assets outstanding / assets maximum must bepositive" → "... must not be negative" (each guards
< 0).LoanPay.cpp— assert description "positive vault and broker balances" → "non-negativevault and broker balances" (guards
>= 0).A full sweep of the lending-protocol files confirmed these are the only mismatches;
LoanInvariant/LoanBrokerInvariantalready use "is negative" / "is zero or negative"correctly, and the remaining "positive" mentions are code comments or genuinely
strict-positive checks (
<= 0).API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)Test Plan
Updated the affected expectations in
Invariants_test.cppand confirmed the invariantsuite passes with the new wording. Both test sets are green (
xrpld --unittestandctest --preset conan-debug). No logic changed, so no new tests were added.