diff --git a/cmd/crates/soroban-test/tests/it/init.rs b/cmd/crates/soroban-test/tests/it/init.rs index c3cc9b6941..f90a0cb15a 100644 --- a/cmd/crates/soroban-test/tests/it/init.rs +++ b/cmd/crates/soroban-test/tests/it/init.rs @@ -1,14 +1,13 @@ use assert_fs::prelude::*; use predicates::prelude::predicate; -use soroban_test::{AssertExt, TestEnv}; +use soroban_test::TestEnv; #[test] fn init() { let sandbox = TestEnv::default(); - let major = soroban_cli::commands::version::pkg() - .split('.') - .next() - .unwrap(); + let cli_version = soroban_cli::commands::version::pkg(); + let major = cli_version.split('.').next().unwrap(); + let is_rc = cli_version.contains("rc"); sandbox .new_assert_cmd("contract") .arg("init") @@ -20,68 +19,12 @@ fn init() { .child("Cargo.toml") .assert(predicate::function(|c: &str| { let table = toml::from_str::(c).unwrap(); - table["workspace"]["dependencies"]["soroban-sdk"].as_str() - == Some(&format!("{major}.0.0")) + let sdk_version = table["workspace"]["dependencies"]["soroban-sdk"].as_str(); + println!("Check expected version {major}.0.0 matches template's {sdk_version:?}"); + if is_rc { + sdk_version.map(|x| x.split('-').next()).flatten() == Some(&format!("{major}.0.0")) + } else { + sdk_version == Some(&format!("{major}.0.0")) + } })); } - -#[test] -fn init_and_deploy() { - let name = "hello_world"; - let sandbox = TestEnv::default(); - - sandbox - .new_assert_cmd("contract") - .arg("init") - .arg("--name") - .arg(name) - .arg("project") - .assert() - .success(); - - let manifest_path = sandbox - .dir() - .join(format!("project/contracts/{name}/Cargo.toml")); - assert!(manifest_path.exists()); - - sandbox - .new_assert_cmd("contract") - .arg("build") - .arg("--manifest-path") - .arg(manifest_path) - .assert() - .success(); - - let target_dir = sandbox - .dir() - .join("project/target/wasm32-unknown-unknown/release"); - assert!(target_dir.exists()); - - let assert = sandbox - .new_assert_cmd("contract") - .arg("deploy") - .arg("--wasm") - .arg(target_dir.join(format!("{name}.wasm"))) - .assert(); - - let contract = assert.stdout_as_str(); - - assert.success(); - - let assert = sandbox - .new_assert_cmd("contract") - .arg("invoke") - .arg("--id") - .arg(contract) - .arg("--") - .arg("hello") - .arg("--to") - .arg("bar") - .assert(); - - let output = assert.stdout_as_str(); - - assert_eq!(output, r#"["Hello","bar"]"#); - - assert.success(); -} diff --git a/cmd/crates/soroban-test/tests/it/integration.rs b/cmd/crates/soroban-test/tests/it/integration.rs index 3ec0d61ed8..c7a3fbec5c 100644 --- a/cmd/crates/soroban-test/tests/it/integration.rs +++ b/cmd/crates/soroban-test/tests/it/integration.rs @@ -4,6 +4,7 @@ mod cookbook; mod custom_types; mod dotenv; mod hello_world; +mod init; mod keys; mod snapshot; mod tx; diff --git a/cmd/crates/soroban-test/tests/it/integration/init.rs b/cmd/crates/soroban-test/tests/it/integration/init.rs new file mode 100644 index 0000000000..e47d44c818 --- /dev/null +++ b/cmd/crates/soroban-test/tests/it/integration/init.rs @@ -0,0 +1,62 @@ +use soroban_test::{AssertExt, TestEnv}; + +#[test] +fn init_and_deploy() { + let name = "hello_world"; + let sandbox = TestEnv::default(); + + sandbox + .new_assert_cmd("contract") + .arg("init") + .arg("--name") + .arg(name) + .arg("project") + .assert() + .success(); + + let manifest_path = sandbox + .dir() + .join(format!("project/contracts/{name}/Cargo.toml")); + assert!(manifest_path.exists()); + + sandbox + .new_assert_cmd("contract") + .arg("build") + .arg("--manifest-path") + .arg(manifest_path) + .assert() + .success(); + + let target_dir = sandbox + .dir() + .join("project/target/wasm32-unknown-unknown/release"); + assert!(target_dir.exists()); + + let assert = sandbox + .new_assert_cmd("contract") + .arg("deploy") + .arg("--wasm") + .arg(target_dir.join(format!("{name}.wasm"))) + .assert(); + + let contract = assert.stdout_as_str(); + + assert.success(); + + let assert = sandbox + .new_assert_cmd("contract") + .arg("invoke") + .arg("--id") + .arg(contract) + .arg("--") + .arg("hello") + .arg("--to") + .arg("bar") + .assert(); + + let output = assert.stdout_as_str(); + + assert_eq!(output, r#"["Hello","bar"]"#); + + assert.success(); +} diff --git a/cmd/soroban-cli/src/utils/contract-workspace-template/Cargo.toml.removeextension b/cmd/soroban-cli/src/utils/contract-workspace-template/Cargo.toml.removeextension index c0d6366e03..34a2a49381 100644 --- a/cmd/soroban-cli/src/utils/contract-workspace-template/Cargo.toml.removeextension +++ b/cmd/soroban-cli/src/utils/contract-workspace-template/Cargo.toml.removeextension @@ -5,7 +5,7 @@ members = [ ] [workspace.dependencies] -soroban-sdk = "21.0.0" +soroban-sdk = "22.0.0-rc.3" [profile.release] opt-level = "z"