Commit Graph

3 Commits

Author SHA1 Message Date
Vito
64f9c254c1 refactor: Tighten VaultHelpers contracts and extend test coverage
- Document the mutate-then-transfer ordering that every helper follows and
  the caller obligation to discard the ApplyView on non-tesSUCCESS
  (transactor sandbox convention).
- Assert that removeVaultAssets is only called with `amount ==
  sfAssetsAvailable` when FinalRemoval::Yes, so a mis-specified amount can
  no longer zero the Vault fields while leaving dust on the pseudo-account.
- Mirror the `assetsAvailable <= assetsTotal` XRPL_ASSERT_PARTS from
  LoanSet/LoanPay in LoanManage::defaultLoan's fixCleanup3_4_0 branch for
  defense-in-depth parity.
- Extend VaultHelpers_test failure-path cases to pin the mutate-then-
  transfer observable, add a third-party-destination sub-test for
  removeVaultAssets, add a Legacy-vault fixture for moveVaultAssets with
  nonzero valueDelta, and add an MPT-backed fixture covering
  add/removeVaultAssets against the integral-asset transfer path.

Addresses review comments on #7983 from @gregtatcam, @xrplf-ai-reviewer,
and @copilot-pull-request-reviewer.
2026-08-18 11:10:31 +02:00
Vito
db50afa34f test: Cover Vault helper early-return branches
Adds unit-test coverage for three previously-untested branches in
VaultHelpers:

- addVaultAssets propagates a non-tes return when the underlying
  accountSend fails (exercised via a sender with no trust line for the
  vault asset).
- clawbackVaultAssets propagates a non-tes return when its accountSend
  fails (exercised via a synthetic third-party recipient with no trust
  line; the production caller always uses the asset issuer, which
  cannot hit this branch).
- moveVaultAssets short-circuits and returns tesSUCCESS without
  touching accountSendMulti when every recipient's amount is zero
  (exercised via two zero-amount recipients, which still satisfies the
  recipients.size() > 1 precondition).
2026-08-10 16:34:36 +02:00
Vito
80ef2659e0 test: Add unit tests for the Vault balance-mutation helpers
Exercise addVaultAssets, clawbackVaultAssets, removeVaultAssets
(including FinalRemoval::Yes hard-reset and the amount > sfAssetsAvailable
failure path), and moveVaultAssets directly against a real Vault SLE and
ApplyView, built via jtx but bypassing the VaultDeposit/VaultWithdraw/
VaultClawback/LoanSet transactors. Covers zero-amount edges, negative
valueDelta, and the independent amount/valueDelta contract, in addition
to the existing transactor-level coverage in Vault_test.cpp,
LoanSet_test.cpp, etc.
2026-08-10 12:41:00 +02:00