chore: migrate rust/guards to icp-cli#1396
Merged
Merged
Conversation
fa92d10 to
b4d4ceb
Compare
There was a problem hiding this comment.
Pull request overview
Migrates the rust/guards example from dfx to icp-cli, restructuring it into the repo’s newer Rust example layout and updating dependencies to current ic-cdk conventions.
Changes:
- Replaced
dfx.json/PocketIC integration tests withicp.yaml+ a bash-basedtest.shflow. - Restructured the Rust canister into a workspace with
backend/(and updated management canister usage toic-cdk-management-canister). - Added a dedicated CI workflow for
rust/guardsusing the standard ICP dev env container.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| rust/guards/tests/tests.rs | Removed PocketIC-based integration tests. |
| rust/guards/test.sh | Added icp-cli-driven integration tests for guard + async behavior. |
| rust/guards/rust-toolchain.toml | Simplified toolchain configuration (targets only). |
| rust/guards/README.md | Updated docs to icp-cli commands and refreshed links/content. |
| rust/guards/icp.yaml | Added icp-cli project definition for the backend canister. |
| rust/guards/guards.did | Removed dfx-era candid file. |
| rust/guards/dfx.json | Removed dfx project configuration. |
| rust/guards/Cargo.toml | Converted to a workspace root manifest. |
| rust/guards/Cargo.lock | Updated lockfile for the new workspace + dependency set. |
| rust/guards/BUILD.md | Removed ICP Ninja/dfx migration doc. |
| rust/guards/backend/lib.rs | Updated raw_rand call to ic-cdk-management-canister and added export_candid!(). |
| rust/guards/backend/Cargo.toml | Added backend crate manifest with updated dependencies. |
| rust/guards/.devcontainer/devcontainer.json | Removed per-example devcontainer config. |
| .github/workflows/guards.yml | Added CI workflow that deploys and runs test.sh. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace dfx.json with icp.yaml using @dfinity/rust@v3.3.0, restructure source into backend/ subdirectory, update management canister usage to ic-cdk-management-canister, add Makefile with guard behavior tests, and add CI workflow. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Transitive dependencies pulled in by ic-cdk 0.20 require edition2024 support (stabilized in Rust 1.85). Removing the 1.78 pin lets rustup use the current stable toolchain. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Required for the icp-cli recipe to extract the Candid interface from the compiled WASM via get_candid_pointer. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ster calls The panicking calls return a non-zero exit code (canister rejection). In the old script, 'A && B; C' meant if B failed, set -e exited before C ran — so the assertion after the panic was never checked. Fix: split setup and panicking call onto separate lines, add '|| true' to the panicking call to explicitly allow failure. The setup call still uses '&&' so it fails loudly if the state reset itself fails. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lock - Restore #inter-canister-calls-and-rollbacks and #securely-handle-traps-in-callbacks fragment identifiers that were dropped during migration - Remove redundant networks block from icp.yaml (managed mode is default) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The old URL now redirects to the inter-canister calls page. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
32ac3ee to
41cb6ce
Compare
- Restore backend/tests/tests.rs with pocket-ic 14.0.0 API (updated from original v5 — WasmResult/UserError replaced by direct Vec<u8>/RejectResponse) - Covers all original scenarios including parallel processing prevention (submit_call/await_call for concurrent calls — not expressible in bash) - Fix remaining building-apps/ doc links to guides/security/inter-canister-calls - README explains both test approaches and how to run PocketIC tests locally - CI downloads pocket-ic server via gh release download (authenticated, no rate limit risk) and runs cargo test as a separate step Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Capture stderr from expected-panicking calls and verify it contains 'panicking callback!' — same check the PocketIC tests perform. Extracted into assert_traps() helper to avoid repetition. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
gh CLI is not available in the icp-dev-env-rust container. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 14 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
rust/guards/backend/tests/tests.rs:13
FutureTypeis passed tocandid::Encode!()in several calls below, but it only derivesCandidType.Encode!requires the values to implementserde::Serialize, so this enum should also deriveSerialize(and import it) to avoid a compile error in the integration tests.
gregorydemay
approved these changes
Jun 19, 2026
Replaces manual curl download with the official dfinity/pocketic composite action — handles OS/arch detection, rate-limit-safe, sets POCKET_IC_BIN automatically. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
raymondk
approved these changes
Jun 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Migrates
rust/guardsfrom dfx to icp-cli.Removed:
dfx.json,BUILD.md,guards.did,.devcontainer/Changed:
src/lib.rstobackend/lib.rswith a workspaceCargo.tomlat rootic_cdk::api::management_canistertoic-cdk-management-canister = "0.1.1"Added:
icp.yamlwith@dfinity/rust@v3.3.0recipetest.shwith 5 tests covering guard/async behavior (TrueAsyncCall vs FalseAsyncCall, state reset) via icp-cli — demonstrates the icp-cli workflowbackend/tests/tests.rs— PocketIC integration tests (updated from the originaltests/to pocket-ic 14.0.0 API) covering the same scenarios plus parallel processing prevention, which requires PocketIC'ssubmit_call/await_callto test concurrent calls.github/workflows/guards.ymlrunning bothbash test.shandcargo testTest plan
icp network start -d && icp deploy && bash test.shpasses locallycargo build --package backend --target wasm32-unknown-unknown --release && cargo test --package backendpasses locally (requires PocketIC server)🤖 Generated with Claude Code