Skip to content

Commit

Permalink
chore(execution-environment): Specify image-classification canister W…
Browse files Browse the repository at this point in the history
…ASM as a Bazel dependency (#3355)

This PR makes image-classification.wasm.gz (currently, a checked-in
binary artifact) a Bazel dependency, so multiple tests that require
either specifically this canister, or just a very large WASM, can share
it. This change required adjusting
`//rs/execution_environment:execution_environment_misc_integration_tests/smoke`.
  • Loading branch information
aterga authored Jan 8, 2025
1 parent 4f3b77e commit 9377651
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions rs/execution_environment/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,13 @@ rust_ic_test_suite(
"//rs/rust_canisters/backtrace_canister:backtrace-canister",
"//rs/universal_canister/impl:universal_canister.module",
"//rs/universal_canister/impl:universal_canister.wasm.gz",
"//testnet/prebuilt-canisters:image-classification",
],
env = dict(ENV.items() + [
("BACKTRACE_CANISTER_WASM_PATH", "$(rootpath //rs/rust_canisters/backtrace_canister:backtrace-canister)"),
("UNIVERSAL_CANISTER_WASM_PATH", "$(rootpath //rs/universal_canister/impl:universal_canister.wasm.gz)"),
("UNIVERSAL_CANISTER_SERIALIZED_MODULE_PATH", "$(rootpath //rs/universal_canister/impl:universal_canister.module)"),
("IMAGE_CLASSIFICATION_CANISTER_WASM_PATH", "$(rootpath //testnet/prebuilt-canisters:image-classification)"),
]),
proc_macro_deps = MACRO_DEPENDENCIES + MACRO_DEV_DEPENDENCIES,
tags = [
Expand Down
12 changes: 10 additions & 2 deletions rs/execution_environment/tests/smoke.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@ const COPYING_GC: &[u8] = include_bytes!("test-data/copying-gc.wasm.gz");
const SHA256: &[u8] = include_bytes!("test-data/sha256.wasm");

// https://github.com/dfinity/examples/tree/master/rust/image-classification
const IMAGE_CLASSIFICATION: &[u8] = include_bytes!("test-data/image-classification.wasm.gz");
fn image_classification_canister_wasm() -> Vec<u8> {
let image_classification_canister_wasm_path =
std::env::var("IMAGE_CLASSIFICATION_CANISTER_WASM_PATH")
.expect("Please ensure that this Bazel test target correctly specifies env and data.");

let wasm_path = std::path::PathBuf::from(image_classification_canister_wasm_path);

std::fs::read(&wasm_path).expect("Failed to read WASM file")
}

#[test]
fn qr() {
Expand Down Expand Up @@ -89,7 +97,7 @@ fn image_classification() {
let env = StateMachine::new();
let image_classification = env
.install_canister(
IMAGE_CLASSIFICATION.to_vec(),
image_classification_canister_wasm(),
encode_args(()).unwrap(),
None,
)
Expand Down
7 changes: 7 additions & 0 deletions testnet/prebuilt-canisters/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package(default_visibility = ["//visibility:public"])

# https://github.com/dfinity/examples/tree/master/rust/image-classification
filegroup(
name = "image-classification",
srcs = ["image-classification.wasm.gz"],
)

0 comments on commit 9377651

Please sign in to comment.