refactor: Split LoanInvariant into LoanBrokerInvariant and LoanInvariant#6674
refactor: Split LoanInvariant into LoanBrokerInvariant and LoanInvariant#6674
Conversation
Separate ValidLoanBroker and ValidLoan into their own header/source file pairs, following the existing pattern of other invariant files (e.g. AMMInvariant, VaultInvariant).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #6674 +/- ##
=======================================
Coverage 81.5% 81.5%
=======================================
Files 998 999 +1
Lines 74456 74456
Branches 7578 7555 -23
=======================================
+ Hits 60648 60652 +4
+ Misses 13808 13804 -4
🚀 New features to boost your workflow:
|
| } | ||
| if (after->at(sfDebtTotal) < 0) | ||
| { | ||
| JLOG(j.fatal()) << "Invariant failed: Loan Broker debt total is negative"; |
There was a problem hiding this comment.
@Tapanito Although a structural change only, as you told the AI bot, it would be a good idea to add:
- An LCOV exclusion, and
- An UNREACHABLE statement
here and below, if these places are not reached via unit tests / cannot be reached ever.
It's fine to do this in a follow-up PR, and probably should be part of a larger, comprehensive effort to do this properly across all invariants.
There was a problem hiding this comment.
Thanks @bthomee, I will do this as part of Lending Protocol invariants. They are a little bit scant at the moment.
| if (indexes.size() == 1) | ||
| { | ||
| auto const index = indexes.value().front(); | ||
| auto const sle = view.read(keylet::unchecked(index)); |
There was a problem hiding this comment.
keylet::unchecked weakens invariant safety — directory entries can hold heterogeneous types, but add a comment explaining why unchecked is required here:
// keylet::unchecked is intentional: the directory may hold either
// ltRIPPLE_STATE or ltMPTOKEN entries; no single typed keylet covers
// both. The type is validated immediately below.
auto const sle = view.read(keylet::unchecked(index));
Separate ValidLoanBroker and ValidLoan into their own header/source file pairs, following the existing pattern of other invariant files (e.g. AMMInvariant, VaultInvariant).
High Level Overview of Change
Context of Change
API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)