Skip to content

refactor(ci): use PocketIC with_icp_features for system canister setup#621

Open
aterga wants to merge 17 commits intomainfrom
arshavir/use-pocketic-system-canisters
Open

refactor(ci): use PocketIC with_icp_features for system canister setup#621
aterga wants to merge 17 commits intomainfrom
arshavir/use-pocketic-system-canisters

Conversation

@aterga
Copy link
Copy Markdown
Contributor

@aterga aterga commented Mar 27, 2026

Summary

  • Upgrade pocket-ic 9.0.2 → 10.0.0 to use PocketIcBuilder::with_icp_features(), which automatically bootstraps ICP ledger, ICP index, and CMC system canisters
  • Remove ~400 lines of manual canister creation/installation code from integration test setup
  • Clean up dead system canister functions and CLI options from the orbit dev script
  • Remove NNS canister WASM downloads (icp_ledger, icp_index, cmc) from the test runner script

Test plan

  • Run cargo check --package integration-tests (passes locally)
  • Run ./scripts/run-integration-tests.sh to verify all integration tests pass with the new PocketIC-managed system canisters
  • Verify orbit --init still works for local dev setup

🤖 Generated with Claude Code

@aterga aterga requested a review from a team as a code owner March 27, 2026 12:33
@aterga aterga changed the title refactor: use PocketIC with_icp_features for system canister setup refactor(ci): use PocketIC with_icp_features for system canister setup Mar 27, 2026
@aterga aterga force-pushed the arshavir/use-pocketic-system-canisters branch from cba25e1 to e1af296 Compare March 27, 2026 13:18
Rust 1.88.0 stabilizes let chains and enables the
`uninlined_format_args` clippy lint. Fix all instances of
`format!("{}", x)` -> `format!("{x}")` across the workspace
to keep CI green under `-D clippy::all`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@aterga aterga force-pushed the arshavir/use-pocketic-system-canisters branch from c53b832 to cf4ca5b Compare March 27, 2026 18:32
@aterga aterga changed the base branch from main to arshavir/rust-1.88-toolchain-bump March 27, 2026 18:32
aterga and others added 7 commits March 30, 2026 10:15
The integration tests and e2e tests were failing because external
dependencies were fetched from unpinned sources (latest/master):

- assetstorage.wasm downloaded from dfinity/sdk master now imports
  env_var_count from ic0, which PocketIC server 9.0.3 does not support
- Internet Identity latest release changed its UI, removing the
  #registerButton element expected by e2e tests

Pin both to known-working versions:
- assetstorage.wasm: pin to SDK commit d65717bd (matching the
  ic-certified-assets git dependency already in Cargo.lock)
- Internet Identity: pin to release-2025-08-29 (last release before
  the final successful CI run)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace manual installation of ICP ledger, ICP index, and CMC with
PocketIC's built-in `with_icp_features` API, which automatically
bootstraps these system canisters. This eliminates ~400 lines of
setup code, removes NNS canister WASM downloads from the test script,
and cleans up dead system canister functions from the orbit dev script.

- Upgrade pocket-ic 9.0.2 → 10.0.0 and server 9.0.3 → 10.0.0
- Remove manual canister creation/init for ICP ledger, index, CMC
- Remove unused types (CMC init args, subnet assignment args, etc.)
- Clean up orbit script: remove --init-cmc, --init-icp-ledger, etc.
- Remove cmc entry from dfx.json

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…rest

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…file

The rebase accidentally kept ic-management-canister-types 0.4.1 from
the base branch. Revert to 0.3.0 (matching main) to avoid duplicate
versions that cause type mismatches with pocket-ic's re-exported types.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The station canister now uses the ic0::env_var_count API (via
dependencies), which PocketIC server 10.0.0 doesn't support. Bump
the server binary to 13.0.0 while keeping the pocket-ic crate at
10.0.0 (11+ requires Rust 1.88, project uses 1.87). The server
REST API changes between 10 and 13 are additive/non-breaking.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
pocket-ic 10.0.0's with_icp_features bundles NNS system canister
WASMs that use ic0::env_var_count, which the PocketIC 10.0.0 server's
Wasm engine doesn't support. Upgrading both crate and server to 13.0.0
resolves the mismatch. This requires Rust 1.88 (bumped in the
preceding commit via arshavir/rust-1.88-toolchain-bump).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@aterga aterga force-pushed the arshavir/use-pocketic-system-canisters branch from cf4ca5b to f7ac2f8 Compare March 30, 2026 08:27
Base automatically changed from arshavir/rust-1.88-toolchain-bump to main April 1, 2026 18:29
@aterga aterga requested a review from a team as a code owner April 1, 2026 18:29
aterga and others added 2 commits April 1, 2026 23:35
….0.0

pocket-ic 13.0.0 depends on ic-management-canister-types 0.5.0, causing
type mismatches when the project used 0.3.x. Align versions to resolve
the "two different versions of crate" compilation errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@aterga aterga force-pushed the arshavir/use-pocketic-system-canisters branch from 45c0298 to b3658f5 Compare April 2, 2026 10:52
PocketIC's with_icp_features(DefaultConfig) doesn't set initial balances
for test accounts. Mint ICP to the test controller after the ledger is
bootstrapped so tests that transfer ICP don't fail with InsufficientFunds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@aterga aterga force-pushed the arshavir/use-pocketic-system-canisters branch from b3658f5 to 2b31cd5 Compare April 2, 2026 14:43
@aterga aterga requested a review from sea-snake April 2, 2026 14:47
@aterga aterga changed the title refactor(ci): use PocketIC with_icp_features for system canister setup refactor(ci): use PocketIC with_icp_features for system canister setup Apr 2, 2026
aterga and others added 3 commits April 2, 2026 18:13
…ance count

pocket-ic 13.0.0 server crashes (ConnectionReset) when many PocketIC
instances are created concurrently in integration tests. Downgrading to
12.0.0 which has the same with_icp_features API but a more stable server.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Relax error message assertion in failed_system_restore test to match
  across pocket-ic versions (error format changed)
- Widen timestamp tolerance in upgrader migration test from 1ms to 1s
  since system canister initialization can advance time differently

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
After upgrading from a pre-built stable-memory binary (v1), the recovery
request timestamps originate from the binary's PocketIC genesis time,
which differs from the current run's genesis time (with_icp_features
uses a different default). Replace the tight tolerance check with a
count assertion and RFC 3339 validation, keeping the timestamp
normalization for the subsequent deep comparison.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
aterga and others added 3 commits April 3, 2026 10:27
The Duration import was removed but a second usage in the log timestamp
comparison was missed, causing a compilation error. Apply the same fix:
validate RFC 3339 format without strict time matching, since pre-built
stable-memory binaries have different genesis times.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rtions

`with_icp_features` with `cycles_minting` changes PocketIC's default
time from the IC genesis (2021-05-06T19:17:10 UTC) to the CMC's default
ICP/XDR conversion-rate timestamp + 1s (2021-05-10T08:00:01 UTC).
Pre-built stable-memory binaries (upgrader-memory-v1.bin) were generated
under the old genesis, so we now set the time to IC genesis explicitly
when `set_time_to_now` is false. This lets us restore the original
precise (1ms) timestamp assertions in the upgrader migration tests.

See: https://github.com/dfinity/ic/blob/master/rs/pocket_ic_server/src/pocket_ic.rs
     (the `default_timestamp` function)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PocketIC with `cycles_minting` feature sets default time to
2021-05-10T08:00:01 UTC (CMC conversion-rate timestamp + 1s) and
does not allow setting time to an earlier value. Pre-built
stable-memory binaries (v0/v1) were recorded under the IC genesis
time (2021-05-06T19:17:10 UTC), so timestamps cannot match after
loading those binaries.

Add a `check_timestamps` parameter to `test_api()`:
- `true` before migration (timestamps are from the current run)
- `false` after loading a pre-built binary (timestamps differ)

The structural deep-comparison of recovery requests and logs is
still performed in all cases; only the tight 1 ms tolerance check
is gated.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants