From c5f3a8c9ef04a3f25dea9c8e4bb7244eff6c422a Mon Sep 17 00:00:00 2001 From: Blaine Heffron Date: Wed, 21 Aug 2024 17:24:20 -0400 Subject: [PATCH] formatting --- .../soroban-test/tests/it/integration.rs | 2 +- .../tests/it/integration/cookbook.rs | 73 ++++++++++++++----- cmd/crates/soroban-test/tests/it/main.rs | 1 + 3 files changed, 58 insertions(+), 18 deletions(-) diff --git a/cmd/crates/soroban-test/tests/it/integration.rs b/cmd/crates/soroban-test/tests/it/integration.rs index 713aa6125..3e8521869 100644 --- a/cmd/crates/soroban-test/tests/it/integration.rs +++ b/cmd/crates/soroban-test/tests/it/integration.rs @@ -7,4 +7,4 @@ mod hello_world; mod snapshot; mod tx; mod util; -mod wrap; \ No newline at end of file +mod wrap; diff --git a/cmd/crates/soroban-test/tests/it/integration/cookbook.rs b/cmd/crates/soroban-test/tests/it/integration/cookbook.rs index b37feeba5..6c73601af 100644 --- a/cmd/crates/soroban-test/tests/it/integration/cookbook.rs +++ b/cmd/crates/soroban-test/tests/it/integration/cookbook.rs @@ -11,7 +11,16 @@ fn parse_command(command: &str) -> Vec { .collect() } -async fn run_command(sandbox: &TestEnv, command: &str, wasm_path: &str, wasm_hash: &str, source: &str, contract_id: &str, bob_id: &str, native_id: &str) -> Result<(), String> { +async fn run_command( + sandbox: &TestEnv, + command: &str, + wasm_path: &str, + wasm_hash: &str, + source: &str, + contract_id: &str, + bob_id: &str, + native_id: &str, +) -> Result<(), String> { if command.contains("export") { return Ok(()); } @@ -19,7 +28,7 @@ async fn run_command(sandbox: &TestEnv, command: &str, wasm_path: &str, wasm_has if args.is_empty() { return Err("Empty command".to_string()); } - if command.contains("contract asset deploy"){ + if command.contains("contract asset deploy") { return Ok(()); } /*if command.contains("keys generate"){ @@ -40,48 +49,48 @@ async fn run_command(sandbox: &TestEnv, command: &str, wasm_path: &str, wasm_has modified_args.push(arg.to_string()); modified_args.push(wasm_path.to_string()); skip_next = true; - }, + } "--wasm-hash" => { modified_args.push(arg.to_string()); modified_args.push(wasm_hash.to_string()); skip_next = true; - }, + } "--source" | "--source-account" => { modified_args.push(arg.to_string()); modified_args.push(source.to_string()); skip_next = true; - }, + } "--contract-id" | "--id" => { modified_args.push(arg.to_string()); modified_args.push(contract_id.to_string()); skip_next = true; - }, + } "--network-passphrase" => { modified_args.push(arg.to_string()); modified_args.push(LOCAL.to_string()); skip_next = true; - }, + } "--network" => { modified_args.push(arg.to_string()); modified_args.push("local".to_string()); skip_next = true; - }, + } "" => { modified_args.push("persistent".to_string()); skip_next = false; - }, + } "" => { modified_args.push("COUNTER".to_string()); skip_next = false; - }, + } "" => { modified_args.push(bob_id.to_string()); skip_next = false; - }, + } "" => { modified_args.push(native_id.to_string()); skip_next = false; - }, + } _ => modified_args.push(arg.to_string()), } @@ -103,7 +112,16 @@ async fn run_command(sandbox: &TestEnv, command: &str, wasm_path: &str, wasm_has Ok(()) } -async fn test_mdx_file(sandbox: &TestEnv, file_path: &str, wasm_path: &str, wasm_hash: &str, source: &str, contract_id: &str, bob_id: &str, native_id: &str) -> Result<(), String> { +async fn test_mdx_file( + sandbox: &TestEnv, + file_path: &str, + wasm_path: &str, + wasm_hash: &str, + source: &str, + contract_id: &str, + bob_id: &str, + native_id: &str, +) -> Result<(), String> { let content = fs::read_to_string(file_path) .map_err(|e| format!("Failed to read file {}: {}", file_path, e))?; @@ -117,7 +135,17 @@ async fn test_mdx_file(sandbox: &TestEnv, file_path: &str, wasm_path: &str, wasm for (i, command) in commands.iter().enumerate() { println!("Running command {}: {}", i + 1, command); - run_command(sandbox, command, wasm_path, wasm_hash, source, contract_id, bob_id, native_id).await?; + run_command( + sandbox, + command, + wasm_path, + wasm_hash, + source, + contract_id, + bob_id, + native_id, + ) + .await?; } Ok(()) @@ -147,14 +175,14 @@ mod tests { let wasm_path = wasm.path(); let wasm_hash = wasm.hash().expect("should exist").to_string(); let source = "test"; - + sandbox .new_assert_cmd("keys") .arg("fund") .arg(source) .assert() .success(); - + sandbox .new_assert_cmd("keys") .arg("generate") @@ -211,7 +239,18 @@ mod tests { } let file_path = path.to_str().unwrap(); - match test_mdx_file(&sandbox, file_path, &wasm_path.to_str().unwrap(), &wasm_hash, source, &contract_id, &bob_id, &native_id).await { + match test_mdx_file( + &sandbox, + file_path, + &wasm_path.to_str().unwrap(), + &wasm_hash, + source, + &contract_id, + &bob_id, + &native_id, + ) + .await + { Ok(_) => println!("Successfully tested all commands in {}", file_path), Err(e) => panic!("Error testing {}: {}", file_path, e), } diff --git a/cmd/crates/soroban-test/tests/it/main.rs b/cmd/crates/soroban-test/tests/it/main.rs index 6f13d3174..5a0b2a07f 100644 --- a/cmd/crates/soroban-test/tests/it/main.rs +++ b/cmd/crates/soroban-test/tests/it/main.rs @@ -3,6 +3,7 @@ mod build; mod config; mod help; mod init; +#[cfg(feature = "it")] mod integration; mod plugin; mod util;