mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-28 17:40:25 +00:00
Add unit tests for invariant checks
Signed-off-by: JCW <a1q123456@users.noreply.github.com>
This commit is contained in:
@@ -1987,6 +1987,7 @@ class Invariants_test : public beast::unit_test::suite
|
||||
[](SLE::pointer& sle) { sle->at(sfManagementFeeRate) += 1; },
|
||||
[](SLE::pointer& sle) { sle->at(sfCoverRateMinimum) += 1; },
|
||||
[](SLE::pointer& sle) { sle->at(sfCoverRateLiquidation) += 1; },
|
||||
[](SLE::pointer& sle) { sle->setFlag(lsfLoanBrokerPrivate); },
|
||||
[](SLE::pointer& sle) { sle->at(sfLedgerEntryType) += 1; },
|
||||
[](SLE::pointer& sle) { sle->at(sfLedgerIndex) = sle->at(sfVaultID).value(); },
|
||||
});
|
||||
@@ -2251,6 +2252,25 @@ class Invariants_test : public beast::unit_test::suite
|
||||
STTx{ttLOAN_BROKER_SET, [](STObject& tx) {}},
|
||||
{tecINVARIANT_FAILED, tefINVARIANT_FAILED},
|
||||
createLoanBroker);
|
||||
|
||||
doInvariantCheck(
|
||||
{{"DomainID is set on public Loan Broker"}},
|
||||
[&](Account const& A1, Account const& A2, ApplyContext& ac) {
|
||||
if (loanBrokerKeylet.type != ltLOAN_BROKER)
|
||||
return false;
|
||||
auto sleBroker = ac.view().peek(loanBrokerKeylet);
|
||||
if (!sleBroker)
|
||||
return false;
|
||||
// Set DomainID without lsfLoanBrokerPrivate flag
|
||||
sleBroker->clearFlag(lsfLoanBrokerPrivate);
|
||||
sleBroker->at(sfDomainID) = uint256(42);
|
||||
ac.view().update(sleBroker);
|
||||
return true;
|
||||
},
|
||||
XRPAmount{},
|
||||
STTx{ttLOAN_BROKER_SET, [](STObject& tx) {}},
|
||||
{tecINVARIANT_FAILED, tefINVARIANT_FAILED},
|
||||
createLoanBroker);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user