From 9a63aa6df230b78666ae1d5dc095752da394ecf2 Mon Sep 17 00:00:00 2001 From: Alejandro Martinez Andres <11448715+al3mart@users.noreply.github.com> Date: Wed, 18 Dec 2024 12:18:20 +0100 Subject: [PATCH 1/3] test: include instantiate_call_data_works --- crates/pop-cli/src/commands/up/contract.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/pop-cli/src/commands/up/contract.rs b/crates/pop-cli/src/commands/up/contract.rs index 497a01c0..df1edaf6 100644 --- a/crates/pop-cli/src/commands/up/contract.rs +++ b/crates/pop-cli/src/commands/up/contract.rs @@ -483,18 +483,19 @@ mod tests { let localhost_url = format!("ws://127.0.0.1:{}", port); sleep(Duration::from_secs(5)).await; - get_upload_call_data_works(port, temp_dir).await?; + get_upload_call_data_works(port, temp_dir.path().join("testing")).await?; + get_instantiate_call_data_works(port, temp_dir.path().join("testing")).await?; // Stop running contracts-node stop_test_environment(&contracts_node_process.id().to_string())?; Ok(()) } - async fn get_upload_call_data_works(port: u16, temp_dir: TempDir) -> anyhow::Result<()> { + async fn get_upload_call_data_works(port: u16, temp_dir: PathBuf) -> anyhow::Result<()> { let localhost_url = format!("ws://127.0.0.1:{}", port); let up_contract_opts = UpContractCommand { - path: Some(temp_dir.path().join("testing")), + path: Some(temp_dir), constructor: "new".to_string(), args: vec![], value: "0".to_string(), @@ -541,11 +542,11 @@ mod tests { Ok(()) } - async fn get_instantiate_call_data_works(port: u16, temp_dir: TempDir) -> anyhow::Result<()> { + async fn get_instantiate_call_data_works(port: u16, temp_dir: PathBuf) -> anyhow::Result<()> { let localhost_url = format!("ws://127.0.0.1:{}", port); let up_contract_opts = UpContractCommand { - path: Some(temp_dir.path().join("testing")), + path: Some(temp_dir), constructor: "new".to_string(), args: vec!["false".to_string()], value: "0".to_string(), From 206e3dbb73a701371034207529e721e1bb7f4c1e Mon Sep 17 00:00:00 2001 From: AlexD10S Date: Wed, 18 Dec 2024 12:36:06 +0100 Subject: [PATCH 2/3] test: increase sleep time in run_contracts_node --- crates/pop-contracts/src/node/mod.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/pop-contracts/src/node/mod.rs b/crates/pop-contracts/src/node/mod.rs index 425a2d05..e87c9f07 100644 --- a/crates/pop-contracts/src/node/mod.rs +++ b/crates/pop-contracts/src/node/mod.rs @@ -132,8 +132,8 @@ pub async fn run_contracts_node( let process = command.spawn()?; - // Wait 5 secs until the node is ready - sleep(Duration::from_millis(5000)).await; + // Wait 20 secs until the node is ready + sleep(Duration::from_millis(20000)).await; let data = Value::from_bytes(subxt::utils::to_hex("initialize contracts node")); let payload = subxt::dynamic::tx("System", "remark", [data].to_vec()); @@ -165,18 +165,20 @@ fn release_directory_by_target(tag: Option<&str>) -> Result<&'static str, Error> // The structure of the binary changed in v0.42.0 let is_old_structure = matches!(tag, Some(tag) if tag < "v0.42.0"); match OS { - "macos" => + "macos" => { if is_old_structure { Ok("artifacts/substrate-contracts-node-mac/substrate-contracts-node") } else { Ok("substrate-contracts-node-mac/substrate-contracts-node") - }, - "linux" => + } + }, + "linux" => { if is_old_structure { Ok("artifacts/substrate-contracts-node-linux/substrate-contracts-node") } else { Ok("substrate-contracts-node-linux/substrate-contracts-node") - }, + } + }, _ => Err(Error::UnsupportedPlatform { arch: ARCH, os: OS }), } } From 82e96516c835237506f697965439755de325ebff Mon Sep 17 00:00:00 2001 From: AlexD10S Date: Wed, 18 Dec 2024 12:37:30 +0100 Subject: [PATCH 3/3] fix: fmt --- crates/pop-contracts/src/node/mod.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/pop-contracts/src/node/mod.rs b/crates/pop-contracts/src/node/mod.rs index e87c9f07..060dca16 100644 --- a/crates/pop-contracts/src/node/mod.rs +++ b/crates/pop-contracts/src/node/mod.rs @@ -165,20 +165,18 @@ fn release_directory_by_target(tag: Option<&str>) -> Result<&'static str, Error> // The structure of the binary changed in v0.42.0 let is_old_structure = matches!(tag, Some(tag) if tag < "v0.42.0"); match OS { - "macos" => { + "macos" => if is_old_structure { Ok("artifacts/substrate-contracts-node-mac/substrate-contracts-node") } else { Ok("substrate-contracts-node-mac/substrate-contracts-node") - } - }, - "linux" => { + }, + "linux" => if is_old_structure { Ok("artifacts/substrate-contracts-node-linux/substrate-contracts-node") } else { Ok("substrate-contracts-node-linux/substrate-contracts-node") - } - }, + }, _ => Err(Error::UnsupportedPlatform { arch: ARCH, os: OS }), } }