diff --git a/Cargo.lock b/Cargo.lock index 5aed44fbb..bb01b2abe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1850,7 +1850,7 @@ dependencies = [ [[package]] name = "soroban-cli" -version = "0.1.2" +version = "0.3.0" dependencies = [ "assert_cmd", "assert_fs", @@ -2080,38 +2080,6 @@ dependencies = [ "soroban-sdk", ] -[[package]] -name = "soroban-tools" -version = "0.2.1" -dependencies = [ - "assert_cmd", - "assert_fs", - "base64", - "clap", - "clap_complete", - "crate-git-revision 0.0.4", - "csv", - "ed25519-dalek", - "hex", - "jsonrpsee-core", - "jsonrpsee-http-client", - "rand 0.8.5", - "regex", - "serde", - "serde_derive", - "serde_json", - "sha2 0.10.6", - "soroban-env-host 0.0.10 (git+https://github.com/stellar/rs-soroban-env?rev=c148051)", - "soroban-spec", - "soroban-token-spec", - "stellar-strkey 0.0.6 (git+https://github.com/stellar/rs-stellar-strkey?rev=5e582a8)", - "thiserror", - "tokio", - "warp", - "wasm-opt", - "wasmparser 0.90.0", -] - [[package]] name = "soroban-wasmi" version = "0.16.0-soroban2" @@ -2267,14 +2235,14 @@ checksum = "95059e91184749cb66be6dc994f67f182b6d897cb3df74a5bf66b5e709295fd8" [[package]] name = "test_hello_world" -version = "0.2.1" +version = "0.3.0" dependencies = [ "soroban-sdk", ] [[package]] name = "test_invoker_account_exists" -version = "0.2.1" +version = "0.3.0" dependencies = [ "soroban-sdk", ] diff --git a/Cargo.toml b/Cargo.toml index 2e76052b8..cdaabc299 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,54 +1,5 @@ -[package] -name = "soroban-tools" -description = "Soroban Tools" -homepage = "https://github.com/stellar/soroban-cli" -repository = "https://github.com/stellar/soroban-cli" -authors = ["Stellar Development Foundation "] -license = "Apache-2.0" -readme = "README.md" -version = "0.2.1" -edition = "2021" -rust-version = "1.65" -autobins = false -build = "build.rs" - -[build-dependencies] -crate-git-revision = "0.0.4" - -[[bin]] -name = "soroban" -path = "cmd/soroban-cli/src/main.rs" - -[dependencies] -soroban-env-host = { workspace = true, features = ["vm", "serde", "hostfn_log_fmt_values"] } -soroban-spec = { workspace = true } -soroban-token-spec = { workspace = true } -stellar-strkey = { workspace = true } -clap = { version = "3.1.18", features = ["derive", "env"] } -base64 = "0.13.0" -thiserror = "1.0.31" -serde = "1.0.82" -serde_derive = "1.0.82" -serde_json = "1.0.82" -hex = "0.4.3" -tokio = { version = "1", features = ["full"] } -warp = "0.3" -clap_complete = "3.2.3" -rand = "0.8.5" -wasmparser = "0.90.0" -sha2 = "0.10.6" -csv = "1.1.6" -ed25519-dalek = "1.0.1" -jsonrpsee-http-client = "0.15.1" -jsonrpsee-core = "0.15.1" -regex = "1.6.0" -wasm-opt = "0.110.1" - -[dev_dependencies] -assert_cmd = "2.0.4" -assert_fs = "1.0.7" - [workspace] +resolver = "2" members = [ "cmd/soroban-cli", "cmd/soroban-cli/tests/fixtures/test-wasms/hello_world", diff --git a/Makefile b/Makefile index 1eff57c63..e4bfec7a9 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ test: build-test-wasms cargo test --workspace e2e-test: - cargo test --test 'e2e*' -- --ignored + cargo test --test it -- --ignored check: Cargo.lock cargo clippy --all-targets diff --git a/cmd/soroban-cli/Cargo.toml b/cmd/soroban-cli/Cargo.toml index 3aaa39729..99b59ba1f 100644 --- a/cmd/soroban-cli/Cargo.toml +++ b/cmd/soroban-cli/Cargo.toml @@ -6,11 +6,10 @@ repository = "https://github.com/stellar/soroban-cli" authors = ["Stellar Development Foundation "] license = "Apache-2.0" readme = "README.md" -version = "0.1.2" +version = "0.3.0" edition = "2021" rust-version = "1.64" autobins = false -build = "../../build.rs" [[bin]] name = "soroban" diff --git a/build.rs b/cmd/soroban-cli/build.rs similarity index 100% rename from build.rs rename to cmd/soroban-cli/build.rs diff --git a/cmd/soroban-cli/src/deploy.rs b/cmd/soroban-cli/src/deploy.rs index d3e727dfd..a19436bb7 100644 --- a/cmd/soroban-cli/src/deploy.rs +++ b/cmd/soroban-cli/src/deploy.rs @@ -211,13 +211,13 @@ impl Cmd { // Get the account sequence number let public_strkey = stellar_strkey::StrkeyPublicKeyEd25519(key.public.to_bytes()).to_string(); - let account_details = client.get_account(&public_strkey).await?; // TODO: create a cmdline parameter for the fee instead of simply using the minimum fee let fee: u32 = 100; - let sequence = account_details.sequence.parse::()?; let wasm_hash = match contract_src { ContractSource::Wasm(wasm) => { + let account_details = client.get_account(&public_strkey).await?; + let sequence = account_details.sequence.parse::()?; let (tx, hash) = build_install_contract_code_tx( wasm, sequence + 1, @@ -231,9 +231,11 @@ impl Cmd { ContractSource::WasmHash(wasm_hash) => Hash(wasm_hash), }; + let account_details = client.get_account(&public_strkey).await?; + let sequence = account_details.sequence.parse::()?; let (tx, contract_id) = build_create_contract_tx( wasm_hash, - sequence + 2, + sequence + 1, fee, self.network_passphrase.as_ref().unwrap(), salt, diff --git a/cmd/soroban-cli/tests/fixtures/test-wasms/hello_world/Cargo.toml b/cmd/soroban-cli/tests/fixtures/test-wasms/hello_world/Cargo.toml index d9fe976f2..33fe4cdbf 100644 --- a/cmd/soroban-cli/tests/fixtures/test-wasms/hello_world/Cargo.toml +++ b/cmd/soroban-cli/tests/fixtures/test-wasms/hello_world/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test_hello_world" -version = "0.2.1" +version = "0.3.0" authors = ["Stellar Development Foundation "] license = "Apache-2.0" edition = "2021" diff --git a/cmd/soroban-cli/tests/fixtures/test-wasms/invoker_account_exists/Cargo.toml b/cmd/soroban-cli/tests/fixtures/test-wasms/invoker_account_exists/Cargo.toml index c56e09d84..5d78db443 100644 --- a/cmd/soroban-cli/tests/fixtures/test-wasms/invoker_account_exists/Cargo.toml +++ b/cmd/soroban-cli/tests/fixtures/test-wasms/invoker_account_exists/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "test_invoker_account_exists" -version = "0.2.1" +version = "0.3.0" authors = ["Stellar Development Foundation "] license = "Apache-2.0" edition = "2021" diff --git a/tests/it/e2e_rpc_server.rs b/cmd/soroban-cli/tests/it/e2e_rpc_server.rs similarity index 60% rename from tests/it/e2e_rpc_server.rs rename to cmd/soroban-cli/tests/it/e2e_rpc_server.rs index 665de3df6..e531978d5 100644 --- a/tests/it/e2e_rpc_server.rs +++ b/cmd/soroban-cli/tests/it/e2e_rpc_server.rs @@ -1,4 +1,5 @@ use crate::util::{test_wasm, SorobanCommand, Standalone}; +use std::str; // e2e tests are ignore by default #[test] @@ -6,19 +7,20 @@ use crate::util::{test_wasm, SorobanCommand, Standalone}; fn e2e_deploy_and_invoke_contract_against_rpc_server() { // This test assumes a fresh standalone network rpc server on port 8000 - Standalone::new_cmd() + let result = &Standalone::new_cmd() .arg("deploy") .arg("--wasm") .arg(test_wasm("test_hello_world")) - .arg("--salt=0") .assert() - .stdout("b392cd0044315873f32307bfd535a9cbbb0402a57133ff7283afcae66be8174b\n") .stderr("success\nsuccess\n") .success(); + let id = str::from_utf8(&result.get_output().stdout).unwrap().trim(); + Standalone::new_cmd() .arg("invoke") - .arg("--id=b392cd0044315873f32307bfd535a9cbbb0402a57133ff7283afcae66be8174b") + .arg("--id") + .arg(id) .arg("--fn=hello") .arg("--arg=world") .assert() @@ -32,27 +34,34 @@ fn e2e_deploy_and_invoke_contract_against_rpc_server() { #[ignore] fn e2e_install_deploy_and_invoke_contract_against_rpc_server() { // This test assumes a fresh standalone network rpc server on port 8000 - Standalone::new_cmd() + let install_result = Standalone::new_cmd() .arg("install") .arg("--wasm") .arg(test_wasm("test_hello_world")) .assert() - .stdout("86270dcca8dd4e7131c89dcc61223f096d7a1fa4a1d90c39dd6542b562369ecc\n") .stderr("success\n") .success(); - Standalone::new_cmd() + let wasm_hash = str::from_utf8(&install_result.get_output().stdout) + .unwrap() + .trim(); + + let deploy_result = &Standalone::new_cmd() .arg("deploy") - .arg("--wasm-hash=86270dcca8dd4e7131c89dcc61223f096d7a1fa4a1d90c39dd6542b562369ecc") - .arg("--salt=0") + .arg("--wasm-hash") + .arg(wasm_hash) .assert() - .stdout("b392cd0044315873f32307bfd535a9cbbb0402a57133ff7283afcae66be8174b\n") .stderr("success\n") .success(); + let id = str::from_utf8(&deploy_result.get_output().stdout) + .unwrap() + .trim(); + Standalone::new_cmd() .arg("invoke") - .arg("--id=b392cd0044315873f32307bfd535a9cbbb0402a57133ff7283afcae66be8174b") + .arg("--id") + .arg(id) .arg("--fn=hello") .arg("--arg=world") .assert() @@ -66,25 +75,19 @@ fn e2e_install_deploy_and_invoke_contract_against_rpc_server() { fn create_and_invoke_token_contract_against_rpc_server() { // This test assumes a fresh standalone network rpc server on port 8000 - Standalone::new_cmd() - .args([ - "token", - "create", - "--name=Stellar Lumens", - "--symbol=XLM", - "--salt=1", - ]) + let result = Standalone::new_cmd() + .args(["token", "create", "--name=Stellar Lumens", "--symbol=XLM"]) .assert() - .stdout("1bd2a2473623e73904d35a334476d1fe3cd192811bd823b7815fd9ce57c82232\n") .stderr("success\nsuccess\n") .success(); + let id = str::from_utf8(&result.get_output().stdout).unwrap().trim(); + Standalone::new_cmd() - .args([ - "invoke", - "--id=1bd2a2473623e73904d35a334476d1fe3cd192811bd823b7815fd9ce57c82232", - "--fn=symbol", - ]) + .arg("invoke") + .arg("--id") + .arg(id) + .arg("--fn=symbol") .assert() .stdout("[88,76,77]\n") .stderr("success\n") diff --git a/tests/it/invoke_sandbox.rs b/cmd/soroban-cli/tests/it/invoke_sandbox.rs similarity index 100% rename from tests/it/invoke_sandbox.rs rename to cmd/soroban-cli/tests/it/invoke_sandbox.rs diff --git a/tests/it/main.rs b/cmd/soroban-cli/tests/it/main.rs similarity index 100% rename from tests/it/main.rs rename to cmd/soroban-cli/tests/it/main.rs diff --git a/tests/it/util.rs b/cmd/soroban-cli/tests/it/util.rs similarity index 93% rename from tests/it/util.rs rename to cmd/soroban-cli/tests/it/util.rs index 827196563..318a6e0aa 100644 --- a/tests/it/util.rs +++ b/cmd/soroban-cli/tests/it/util.rs @@ -4,7 +4,7 @@ use assert_cmd::Command; use assert_fs::{prelude::PathChild, TempDir}; pub fn test_wasm(name: &str) -> PathBuf { - let mut path = PathBuf::from("target/wasm32-unknown-unknown/test-wasms").join(name); + let mut path = PathBuf::from("../../target/wasm32-unknown-unknown/test-wasms").join(name); path.set_extension("wasm"); assert!(path.is_file(), "File not found: {}. run 'make test-wasms' to generate .wasm files before running this test", path.display()); path