From 27cacd656c81c2ff91352df9559e8f2225ed5321 Mon Sep 17 00:00:00 2001 From: Chad Ostrowski <221614+chadoh@users.noreply.github.com> Date: Wed, 29 Mar 2023 13:45:09 -0400 Subject: [PATCH] rewrite deployer test in new style --- test/doc-tests/tests/it/deployer.rs | 55 ++++++++++++++--------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/test/doc-tests/tests/it/deployer.rs b/test/doc-tests/tests/it/deployer.rs index 93cd8c34..1c773f3d 100644 --- a/test/doc-tests/tests/it/deployer.rs +++ b/test/doc-tests/tests/it/deployer.rs @@ -1,7 +1,7 @@ //! Tests CLI commands from https://soroban.stellar.org/docs/how-to-guides/deployer -use soroban_cli::commands::contract::{deploy, install}; -use soroban_test::{AssertExt, TestEnv, Wasm}; +use soroban_cli::commands::contract::install; +use soroban_test::{TestEnv, Wasm}; const WASM_DEPLOYER_TEST: &Wasm = &Wasm::Release("soroban_deployer_test_contract"); const WASM_DEPLOYER: &Wasm = &Wasm::Release("soroban_deployer_contract"); @@ -12,42 +12,41 @@ const INIT_VALUE: &str = "5"; fn invoke() { TestEnv::with_default(|workspace| { let hash = WASM_DEPLOYER_TEST.hash().unwrap(); - workspace + + // install (aka upload) the bytes + let install_ret = workspace .cmd_arr::(&["--wasm", &WASM_DEPLOYER_TEST.path().to_string_lossy()]) .run_in_sandbox(WASM_DEPLOYER_TEST.bytes()) .unwrap(); - let derived_hash = workspace - .cmd_arr::(&["--wasm-hash", &format!("{hash}")]) - .run_in_sandbox(hash) - .unwrap(); + assert_eq!(hash, install_ret); + // now invoke a 2nd contract, which deploys an instance of the previously-uploaded bytes let new_contract_info_array = workspace - .new_assert_cmd("contract") - .arg("invoke") - .arg("--wasm") - .arg(&WASM_DEPLOYER.path()) - .args(["--id", "0"]) - .arg("--") - .arg("deploy") - .args([ + .invoke(&[ + "--wasm", + &WASM_DEPLOYER.path().to_string_lossy(), + "--id", + "0", + "--", + "deploy", "--salt", "0000000000000000000000000000000000000000000000000000000000000000", + "--wasm_hash", + &hash.to_string(), + "--init_fn", + "init", + "--init_args", + &format!("[{{\"u32\":{INIT_VALUE}}}]"), ]) - .args(["--wasm_hash", &derived_hash]) - .args(["--init_fn", "init"]) - .args(["--init_args", &format!("[{{\"u32\":{INIT_VALUE}}}]")]) - .assert() - .stderr("") - .stdout_as_str(); + .unwrap(); let contract_id = new_contract_info_array.split('"').nth(1).unwrap(); - e.new_assert_cmd("contract") - .arg("invoke") - .args(["--id", contract_id]) - .args(["--", "value"]) - .assert() - .stderr("") - .stdout(format!("{INIT_VALUE}\n")); + assert_eq!( + format!("{INIT_VALUE}"), + workspace + .invoke(&["--id", contract_id, "--", "value",]) + .unwrap() + ); }); }