Skip to content

Commit

Permalink
made the file search more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
maxrobot committed Apr 3, 2024
1 parent 89babb7 commit d8b0707
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions contracts/swap/src/testing/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,22 @@ fn create_mock_spot_market(
}

pub fn wasm_file(contract_name: String) -> String {
let snaked_name = contract_name.replace('-', "_");
let arch = std::env::consts::ARCH;

let target = format!("../../target/wasm32-unknown-unknown/release/{snaked_name}.wasm");

let artifacts_dir =
std::env::var("ARTIFACTS_DIR_PATH").unwrap_or_else(|_| "artifacts".to_string());
let snaked_name = contract_name.replace('-', "_");
format!("../../{artifacts_dir}/{snaked_name}-{arch}.wasm")
let arch_target = format!("../../{artifacts_dir}/{snaked_name}-{arch}.wasm");

if std::path::Path::new(&target).exists() {
target
} else if std::path::Path::new(&arch_target).exists() {
arch_target
} else {
format!("../../{artifacts_dir}/{snaked_name}.wasm")
}
}

pub fn store_code(
Expand Down

0 comments on commit d8b0707

Please sign in to comment.