diff --git a/integration-tests/src/mpc.rs b/integration-tests/src/mpc.rs index 259f1c629..89264fb96 100644 --- a/integration-tests/src/mpc.rs +++ b/integration-tests/src/mpc.rs @@ -8,6 +8,8 @@ use mpc_recovery::Cli; const PACKAGE: &str = "mpc-recovery"; const PACKAGE_MULTICHAIN: &str = "mpc-recovery-node"; +const PACKAGE_CONTRACT: &str = "mpc-contract"; +const TARGET_CONTRACT: &str = "wasm32-unknown-unknown"; /// NodeProcess holds onto the respective handles such that on drop, it will clean /// the running process, task, or thread. @@ -37,11 +39,15 @@ fn target_dir() -> Option { } } -pub async fn build(release: bool) -> anyhow::Result { +async fn build_package( + release: bool, + package: &str, + target: Option<&str>, +) -> anyhow::Result { let mut cmd = Command::new("cargo"); cmd.arg("build") .arg("--package") - .arg(PACKAGE) + .arg(package) .envs(std::env::vars()) .stdout(Stdio::inherit()) .stderr(Stdio::inherit()); @@ -50,9 +56,25 @@ pub async fn build(release: bool) -> anyhow::Result { cmd.arg("--release"); } + if let Some(target) = target { + cmd.arg("--target").arg(target); + } + Ok(cmd.spawn()?.status().await?) } +pub async fn build(release: bool) -> anyhow::Result { + build_package(release, PACKAGE, None).await +} + +pub async fn build_multichain(release: bool) -> anyhow::Result { + build_package(release, PACKAGE_MULTICHAIN, None).await +} + +pub async fn build_multichain_contract() -> anyhow::Result { + build_package(true, PACKAGE_CONTRACT, Some(TARGET_CONTRACT)).await +} + pub async fn spawn(release: bool, node: &str, cli: Cli) -> anyhow::Result { if cfg!(feature = "flamegraph") { let handle: std::thread::JoinHandle> = std::thread::spawn(|| { diff --git a/integration-tests/src/multichain/mod.rs b/integration-tests/src/multichain/mod.rs index 911e5e4b9..d63ce483f 100644 --- a/integration-tests/src/multichain/mod.rs +++ b/integration-tests/src/multichain/mod.rs @@ -68,22 +68,31 @@ pub struct Context<'a> { } pub async fn setup(docker_client: &DockerClient) -> anyhow::Result> { + if !crate::mpc::build_multichain_contract().await?.success() { + anyhow::bail!("failed to prebuild multichain contract"); + } + + let release = true; + if !crate::mpc::build_multichain(release).await?.success() { + anyhow::bail!("failed to prebuild multichain node service"); + } + let docker_network = NETWORK; docker_client.create_network(docker_network).await?; let SandboxCtx { sandbox, worker } = initialize_sandbox(docker_client, NETWORK).await?; let mpc_contract = worker - .dev_deploy(include_bytes!( - "../../../target/wasm32-unknown-unknown/release/mpc_contract.wasm" - )) + .dev_deploy(&std::fs::read( + "../target/wasm32-unknown-unknown/release/mpc_contract.wasm", + )?) .await?; tracing::info!(contract_id = %mpc_contract.id(), "deployed mpc contract"); Ok(Context { docker_client, docker_network: docker_network.to_string(), - release: true, + release, sandbox, worker, mpc_contract,