From bbf8e98688a27c24e930840119138ecc7fc4866c Mon Sep 17 00:00:00 2001 From: Willem Wyndham Date: Fri, 29 Nov 2024 14:52:19 -0500 Subject: [PATCH] fix: add test and fix others --- .../tests/it/integration/hello_world.rs | 5 ++--- .../soroban-test/tests/it/integration/keys.rs | 9 ++++---- .../tests/it/integration/tx/operations.rs | 21 +++++++++++++------ .../soroban-test/tests/it/integration/wrap.rs | 14 +++++++------ 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/cmd/crates/soroban-test/tests/it/integration/hello_world.rs b/cmd/crates/soroban-test/tests/it/integration/hello_world.rs index fd38c2012..b9ed0196f 100644 --- a/cmd/crates/soroban-test/tests/it/integration/hello_world.rs +++ b/cmd/crates/soroban-test/tests/it/integration/hello_world.rs @@ -1,10 +1,9 @@ -use predicates::boolean::PredicateBooleanExt; use soroban_cli::{ commands::{ contract::{self, fetch}, txn_result::TxnResult, }, - config::{address::Address, locator, secret}, + config::{locator, secret}, }; use soroban_rpc::GetLatestLedgerResponse; use soroban_test::{AssertExt, TestEnv, LOCAL_NETWORK_PASSPHRASE}; @@ -19,7 +18,7 @@ async fn invoke_view_with_non_existent_source_account() { let sandbox = &TestEnv::new(); let id = deploy_hello(sandbox).await; let world = "world"; - let mut cmd = hello_world_cmd(&id, world); + let cmd = hello_world_cmd(&id, world); let res = sandbox.run_cmd_with(cmd, "").await.unwrap(); assert_eq!(res, TxnResult::Res(format!(r#"["Hello",{world:?}]"#))); } diff --git a/cmd/crates/soroban-test/tests/it/integration/keys.rs b/cmd/crates/soroban-test/tests/it/integration/keys.rs index 267a0b095..28723b3a1 100644 --- a/cmd/crates/soroban-test/tests/it/integration/keys.rs +++ b/cmd/crates/soroban-test/tests/it/integration/keys.rs @@ -3,13 +3,12 @@ use soroban_test::AssertExt; use soroban_test::TestEnv; fn pubkey_for_identity(sandbox: &TestEnv, name: &str) -> String { - let output = sandbox + sandbox .new_assert_cmd("keys") .arg("address") .arg(name) .assert() - .stdout_as_str(); - return output; + .stdout_as_str() } #[tokio::test] @@ -61,7 +60,7 @@ async fn overwrite_identity() { "error: An identity with the name 'test2' already exists", )); - assert_eq!(initial_pubkey, pubkey_for_identity(&sandbox, "test2")); + assert_eq!(initial_pubkey, pubkey_for_identity(sandbox, "test2")); sandbox .new_assert_cmd("keys") @@ -72,5 +71,5 @@ async fn overwrite_identity() { .stderr(predicate::str::contains("Overwriting identity 'test2'")) .success(); - assert_ne!(initial_pubkey, pubkey_for_identity(&sandbox, "test2")); + assert_ne!(initial_pubkey, pubkey_for_identity(sandbox, "test2")); } diff --git a/cmd/crates/soroban-test/tests/it/integration/tx/operations.rs b/cmd/crates/soroban-test/tests/it/integration/tx/operations.rs index 9fc843df1..8aa2493cb 100644 --- a/cmd/crates/soroban-test/tests/it/integration/tx/operations.rs +++ b/cmd/crates/soroban-test/tests/it/integration/tx/operations.rs @@ -1,4 +1,5 @@ use soroban_cli::{ + config::locator, tx::{builder, ONE_XLM}, utils::contract_id_hash_from_asset, xdr::{self, ReadXdr, SequenceNumber}, @@ -252,19 +253,23 @@ async fn account_merge_with_alias() { #[tokio::test] async fn set_trustline_flags() { let sandbox = &TestEnv::new(); - let (test, issuer) = setup_accounts(sandbox); - let asset = format!("usdc:{issuer}"); - issue_asset(sandbox, &test, &asset, 100_000, 100).await; + let (test, test1) = setup_accounts(sandbox); + let asset = "usdc:test1"; + issue_asset(sandbox, &test, asset, 100_000, 100).await; sandbox .new_assert_cmd("contract") .arg("asset") .arg("deploy") .arg("--asset") - .arg(&asset) + .arg(asset) .assert() .success(); let id = contract_id_hash_from_asset( - asset.parse::().unwrap(), + &format!("usdc:{test1}") + .parse::() + .unwrap() + .resolve(&locator::Args::default()) + .unwrap(), &sandbox.network_passphrase, ); // sandbox @@ -527,7 +532,11 @@ async fn change_trust() { // wrap_cmd(&asset).run().await.unwrap(); let id = contract_id_hash_from_asset( - asset.parse::().unwrap(), + &asset + .parse::() + .unwrap() + .resolve(&locator::Args::default()) + .unwrap(), &sandbox.network_passphrase, ); sandbox diff --git a/cmd/crates/soroban-test/tests/it/integration/wrap.rs b/cmd/crates/soroban-test/tests/it/integration/wrap.rs index 3fef56ef9..961cd6b4a 100644 --- a/cmd/crates/soroban-test/tests/it/integration/wrap.rs +++ b/cmd/crates/soroban-test/tests/it/integration/wrap.rs @@ -1,4 +1,4 @@ -use soroban_cli::{tx::builder, utils::contract_id_hash_from_asset}; +use soroban_cli::{config::locator, tx::builder, utils::contract_id_hash_from_asset}; use soroban_test::{AssertExt, TestEnv, LOCAL_NETWORK_PASSPHRASE}; #[tokio::test] @@ -12,21 +12,23 @@ async fn burn() { .arg("test") .assert() .stdout_as_str(); - let asset = format!("native:{address}"); + let asset = "native"; sandbox .new_assert_cmd("contract") .arg("asset") .arg("deploy") .arg("--source=test") .arg("--asset") - .arg(&asset) + .arg(asset) .assert() .success(); - // wrap_cmd(&asset).run().await.unwrap(); - let asset: builder::Asset = asset.parse().unwrap(); + let asset = asset + .parse::() + .unwrap() + .resolve(&locator::Args::default()) + .unwrap(); let hash = contract_id_hash_from_asset(&asset, &network_passphrase); let id = stellar_strkey::Contract(hash.0).to_string(); - println!("{id}, {address}"); sandbox .new_assert_cmd("contract") .args([