Repository navigation
test(minter): replace the stubbed runtime with a mockall mock of inter-canister calls - #238
gregorydemay wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The test-only migration is internally consistent and adds strict verification without identified regressions.
Review effort: Balanced
Findings: None
What changed in this PR
Replaces queue-based inter-canister stubs with argument-aware mockall expectations, making minter tests validate canisters, methods, arguments, cycles, and call counts.
Changes:
- Adds a Candid-erased mock implementation of
Runtime. - Migrates RPC and ledger tests to explicit call expectations.
- Adds tests for matched, unexpected, and unused expectations.
| File | Description |
|---|---|
minter/src/test_fixtures/runtime.rs |
Implements inter-canister call mocking and expectation builders. |
minter/src/test_fixtures/tests.rs |
Tests expectation matching and failure behavior. |
minter/src/test_fixtures/mod.rs |
Updates fixture terminology. |
minter/src/withdraw/tests.rs |
Validates withdrawal ledger and RPC calls. |
minter/src/rpc/tests.rs |
Validates RPC arguments and submitted signatures. |
minter/src/monitor/tests.rs |
Adds exact status-check and resubmission expectations. |
minter/src/deposit/sweep/timer/tests.rs |
Validates failed sweep submission calls. |
minter/src/deposit/sweep/tests.rs |
Validates deposit-address balance queries. |
minter/src/deposit/sweep/finalize/tests.rs |
Validates transaction lookup signatures. |
minter/src/deposit/manual/tests.rs |
Validates transaction lookups and ledger mint arguments. |
minter/src/consolidate/tests.rs |
Migrates consolidation tests to transaction expectations. |
minter/Cargo.toml |
Adds the test-only async trait dependency. |
Cargo.lock |
Records the minter dependency update. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
5018b47 to
54f231e
Compare
0ada0d1 to
c892b3a
Compare
c892b3a to
1df12a5
Compare
54f231e to
f13d4dd
Compare
1df12a5 to
71a59cf
Compare
f13d4dd to
91e9b86
Compare
…r-canister calls TestCanisterRuntime answered inter-canister calls from an ordered queue of Candid-encoded responses that ignored the arguments of a call. Back it by a mockall mock instead: every test now registers the calls it expects, stating the canister, the method, the arguments, the attached cycles and the response. A call without a matching expectation and an expectation that goes unused both fail the test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
91e9b86 to
7660386
Compare
|
✅ No security or compliance issues detected. Reviewed everything up to d5208e0. Security OverviewDetected Code Changes
|
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The mock update calls do not yield, preventing concurrent tests from modeling inter-canister await boundaries.
1 open finding
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
The mock replacement is consistently applied and preserves asynchronous call behavior while strengthening request verification.
0 open findings
1 resolved since last review
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
There was a problem hiding this comment.
🟢 Approval recommended
The test-only refactor consistently replaces ordered stubs with precise expectations and preserves asynchronous call behavior.
0 open findings
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

TestCanisterRuntimeanswered inter-canister calls with aStubRuntime: an ordered queue of Candid-encoded responses that ignored which method was called and with which arguments. To assert what was sent, the mint tests additionally wrapped it in aRecordingStubRuntimeand compared the recorded arguments after the fact.Both are replaced by a mockall mock. Every test registers the calls it expects upfront, stating the canister, the method, the arguments, the attached cycles and the response — e.g. which signature a
getTransactioncall queries, which address agetBalancecall reads, or the fullicrc1_transferarguments of a pending mint, including thecreated_at_timethe ledger deduplicates retries on. AsendTransactionexpectation matches the submitted transaction by its first signature, i.e. by the fee payer's signature. Each expectation answers exactly one matching call: a call without a matching expectation and an expectation that goes unused both fail the test, which already uncovered one test that queued a recent block the code under test never fetches.The mockall mock is written against a Candid-erased copy of the
Runtimetrait because mockall cannot mock its generic methods directly (expectations need'staticgeneric parameters, which the trait does not require). Failure messages still print the arguments as readable Candid text. The builder style ofTestCanisterRuntime(add_recent_block,transaction_builder, ...) is kept, so tests keep reading as a list of expected calls.🤖 Generated with Claude Code