test(PocketIC): check canister snapshot download without dfx - #10983
Open
mraszyk wants to merge 4 commits into
Open
test(PocketIC): check canister snapshot download without dfx#10983mraszyk wants to merge 4 commits into
mraszyk wants to merge 4 commits into
Conversation
The test `canister_snapshots` used to validate the canister snapshot downloaded by PocketIC by downloading the same snapshot using `dfx` and comparing the two directories. Instead, the test now asserts the expected list of files in the downloaded snapshot directory and their expected contents: - `wasm_module.bin` must match the installed test canister WASM; - `stable_memory.bin` must match the pattern written by the test canister and is absent iff the stable memory is empty; - `wasm_chunk_store/<hash>.bin` must match the uploaded WASM chunks and the directory is absent iff the WASM chunk store is empty; - `metadata.json` is checked field by field after parsing it; - the contents of `wasm_memory.bin` are hard to reproduce and thus only its size is checked (against the WASM memory size in the metadata). This drops the dependency of the test on `dfx` and also makes the test cover the same ground on Windows, where the `dfx` part used to be skipped since there is no Windows build of `dfx`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the packages/pocket-ic canister snapshot integration test to validate snapshot contents directly (without invoking dfx), so the same checks can run on Windows as well as Unix-like platforms.
Changes:
- Reworked the
canister_snapshotstest to assert expected snapshot files and validate file contents/metadata fields directly. - Removed the
dfxruntime dependency from thecanister_snapshotsBazel test target. - Added helper utilities for recursive file listing and optional file-size checks to support the new assertions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/pocket-ic/tests/canister_snapshots.rs | Replaces dfx-based comparison with direct validation of downloaded snapshot files and parsed metadata. |
| packages/pocket-ic/BUILD.bazel | Drops dfx from test data/env for the canister_snapshots target. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…JSON Instead of checking the fields of the canister snapshot metadata one by one, the expected metadata is now assembled into a `ReadCanisterSnapshotMetadataResponse` and compared against the contents of the `metadata.json` file as pretty-printed JSON (line by line so that the error message stays readable). The timestamp and the globals are still checked separately (and copied over into the expected metadata) since the former is only known to be within the interval in which the snapshot was taken and the values of the latter depend on how the test canister WASM is compiled. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The test used to shell out to the external `diff` binary to compare the snapshot directory downloaded from the uploaded snapshot against the originally downloaded snapshot directory. Since the test is supposed to run on all platforms (including Windows, where `diff` is not available), the comparison is now done in pure Rust by comparing the list of files in the two directories and then the contents of each file (except `metadata.json`, which is compared separately after parsing it since some of its fields are expected to differ). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`list_files` only collects files and thus an empty WASM chunk store directory in a downloaded snapshot would go unnoticed. The test now asserts explicitly that the WASM chunk store directory is present if and only if the WASM chunk store is expected to be non-empty (and that the snapshot downloaded after the upload agrees with the originally downloaded one). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
The test
canister_snapshotsused to validate the canister snapshot downloaded by PocketIC by downloading the same snapshot usingdfxand comparing the two directories. Instead, the test now asserts the expected list of files in the downloaded snapshot directory and their expected contents:wasm_module.binmust match the installed test canister WASM;stable_memory.binmust match the pattern written by the test canister and is absent iff the stable memory is empty;wasm_chunk_store/must exist iff the wasm chunk store is not empty;wasm_chunk_store/<hash>.binmust match the uploaded WASM chunks and the directory is absent iff the WASM chunk store is empty;metadata.jsonis checked for equality except for timestamp and globals for which only certain properties are enforced;wasm_memory.binare hard to reproduce and thus only its size is checked (against the WASM memory size in the metadata).This drops the dependency of the test on
dfxand also makes the test cover the same ground on Windows, where thedfxpart used to be skipped since there is no Windows build ofdfx.