test: cover deposit ledger-error mapper arms#157
Conversation
Adds unit tests driving each TransferFromError variant through deposit(): the two payload-carrying arms (InsufficientFunds, InsufficientAllowance) map to their typed DepositError counterparts, and the variants a well-behaved ledger should never return collapse to InternalError carrying the ledger's Display message rather than trapping. Previously only TemporarilyUnavailable was exercised. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
✅ Ready to approve
The change is test-only and correctly exercises each mapper arm with assertions aligned to the production to_ledger_error implementation.
Note: this review does not count toward required approvals for merging.
Pull request overview
Adds missing unit test coverage for deposit()’s TransferFromError -> DepositError mapping, ensuring all to_ledger_error match arms are exercised and that “unexpected” ledger errors are surfaced as InternalError strings rather than trapping.
Changes:
- Add
deposit()tests forInsufficientFundsandInsufficientAllowancemapping (including payload preservation). - Add a table-driven test covering “unexpected”
TransferFromErrorvariants mapping toLedgerTransferFromError::InternalError(format!("{e}")).
File summaries
| File | Description |
|---|---|
| canister/src/tests.rs | Adds unit tests to cover all TransferFromError variants mapped by the deposit error mapper. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0
Note
Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
…iven test Match the codebase convention for error-path coverage (e.g. should_reject_invalid_orders_without_modifying_book): a single test with a (ledger reply, expected DepositError) cases table and one setup, rather than the previous mix of per-variant tests plus a loop. Also covers TemporarilyUnavailable so the table documents the full mapping. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
✅ Ready to approve
The change is isolated to tests and correctly exercises the full error-mapping surface described in the PR without altering production code paths.
Note: this review does not count toward required approvals for merging.
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0 new
Note
Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.
Closes a test gap surfaced during the repo review: of the nine
TransferFromErrorvariants the deposit path translates into_ledger_error, onlyTemporarilyUnavailablewas exercised.Adds unit tests that drive each variant through
deposit()and assert the mapping:InsufficientFunds/InsufficientAllowancecarry their payload into the typedDepositError.BadFee,BadBurn,CreatedInFuture,Duplicate,GenericError,TooOld) collapse toInternalErrorcarrying the ledger's Display message — and notably do not trap.Test-only; no production code changed.