chore: Address inline review comments on Vault helpers

- Restore the doc comment on STAmount::isRounded that was lost when it
  moved out of LendingHelpers.cpp.
- Collapse LoanManage::defaultLoan's Vault-update block into a direct
  return of addVaultAssets, since there is no follow-up work after it.
- Mark removeVaultAssets's amount==0 early-return with LCOV_EXCL_LINE: it
  is a defensive short-circuit for a branch that is only reachable in a
  vanishingly rare edge case (final withdrawal from a vault whose
  sfAssetsAvailable has already been written down to zero) and is not
  reached by any current transactor-level test.
This commit is contained in:
Vito
2026-08-10 16:34:29 +02:00
parent 5d839f4811
commit 0a4dd08700
3 changed files with 12 additions and 12 deletions

View File

@@ -772,6 +772,10 @@ roundToAsset(
return roundToScale(ret, scale);
}
/* Checks if a value is already rounded to the specified scale.
* Returns true if rounding down and rounding up produce the same result,
* indicating no further precision exists beyond the scale.
*/
[[nodiscard]] inline bool
isRounded(Asset const& asset, Number const& value, std::int32_t scale)
{

View File

@@ -307,7 +307,7 @@ removeVaultAssets(
applyRemoveVaultAssets(ctx.view, vault, amount, finalRemoval);
if (amount == beast::kZero)
return tesSUCCESS;
return tesSUCCESS; // LCOV_EXCL_LINE
return doWithdraw(ctx, senderAcct, dstAcct, vault->at(sfAccount), priorBalance, amount, j);
}

View File

@@ -271,17 +271,13 @@ LoanManage::defaultLoan(
// Update the Vault's assets, and return funds from the LoanBroker
// pseudo-account to the Vault pseudo-account:
if (auto const ter = addVaultAssets(
view,
vaultSle,
brokerSle->at(sfAccount),
STAmount{vaultAsset, defaultCovered},
STAmount{vaultAsset, vaultTotalDelta},
j);
!isTesSuccess(ter))
return ter;
return tesSUCCESS;
return addVaultAssets(
view,
vaultSle,
brokerSle->at(sfAccount),
STAmount{vaultAsset, defaultCovered},
STAmount{vaultAsset, vaultTotalDelta},
j);
}
TER