Skip to main content

ic_testkit/artifacts/
wasm.rs

1use std::path::{Path, PathBuf};
2
3/// Resolve one crate's Wasm artifact under a caller-selected Cargo target directory.
4#[must_use]
5pub fn wasm_path(target_dir: &Path, crate_name: &str, profile_target_dir: &str) -> PathBuf {
6    target_dir
7        .join("wasm32-unknown-unknown")
8        .join(profile_target_dir)
9        .join(format!("{crate_name}.wasm"))
10}
11
12/// Check whether every requested Wasm artifact is a regular file.
13#[must_use]
14pub fn wasm_artifacts_ready(
15    target_dir: &Path,
16    canisters: &[&str],
17    profile_target_dir: &str,
18) -> bool {
19    canisters
20        .iter()
21        .all(|name| wasm_path(target_dir, name, profile_target_dir).is_file())
22}