Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat!(CLI): remove sandbox #997

Merged
merged 7 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/crates/soroban-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ fs_extra = "1.3.0"
serde_json = "1.0.93"
which = { workspace = true }
tokio = "1.28.1"

[features]
integration = []
11 changes: 6 additions & 5 deletions cmd/crates/soroban-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl TestEnv {
/// ```rust,no_run
/// use soroban_test::TestEnv;
/// TestEnv::with_default(|env| {
/// env.invoke(&["--id", "1", "--", "hello", "--world=world"]).unwrap();
/// env.new_assert_cmd("contract").args(&["invoke", "--id", "1", "--", "hello", "--world=world"]).assert().success();
/// });
/// ```
///
Expand Down Expand Up @@ -122,7 +122,7 @@ impl TestEnv {
}

/// A convenience method for using the invoke command.
pub fn invoke<I: AsRef<str>>(&self, command_str: &[I]) -> Result<String, invoke::Error> {
pub async fn invoke<I: AsRef<str>>(&self, command_str: &[I]) -> Result<String, invoke::Error> {
let cmd = contract::invoke::Cmd::parse_arg_vec(
&command_str
.iter()
Expand All @@ -131,13 +131,13 @@ impl TestEnv {
.collect::<Vec<_>>(),
)
.unwrap();
self.invoke_cmd(cmd)
self.invoke_cmd(cmd).await
}

/// Invoke an already parsed invoke command
pub fn invoke_cmd(&self, mut cmd: invoke::Cmd) -> Result<String, invoke::Error> {
pub async fn invoke_cmd(&self, mut cmd: invoke::Cmd) -> Result<String, invoke::Error> {
cmd.set_pwd(self.dir());
cmd.run_in_sandbox(&global::Args {
cmd.run_against_rpc_server(&global::Args {
locator: config::locator::Args {
global: false,
config_dir: None,
Expand All @@ -148,6 +148,7 @@ impl TestEnv {
very_verbose: false,
list: false,
})
.await
}

/// Reference to current directory of the `TestEnv`.
Expand Down
24 changes: 2 additions & 22 deletions cmd/crates/soroban-test/tests/it/config.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use assert_fs::TempDir;
use soroban_test::{temp_ledger_file, TestEnv};
use soroban_test::TestEnv;
use std::{fs, path::Path};

use crate::util::{add_identity, add_test_id, SecretKind, DEFAULT_SEED_PHRASE, HELLO_WORLD};
use crate::util::{add_identity, add_test_id, SecretKind, DEFAULT_SEED_PHRASE};
use soroban_cli::commands::config::network;

const NETWORK_PASSPHRASE: &str = "Local Sandbox Stellar Network ; September 2022";
Expand Down Expand Up @@ -205,26 +205,6 @@ fn seed_phrase() {
.stdout("test_seed\n");
}

#[test]
fn use_different_ledger_file() {
let sandbox = TestEnv::default();
sandbox
.new_assert_cmd("contract")
.arg("invoke")
.arg("--id=1")
.arg("--wasm")
.arg(HELLO_WORLD.path())
.arg("--ledger-file")
.arg(temp_ledger_file())
.arg("--")
.arg("hello")
.arg("--world=world")
.assert()
.stdout("[\"Hello\",\"world\"]\n")
.success();
assert!(fs::read(sandbox.dir().join(".soroban/ledger.json")).is_err());
}

#[test]
fn read_address() {
let sandbox = TestEnv::default();
Expand Down
Loading
Loading