From 69fc190e2393894d82a2e062707f59f0ca6456e9 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/tx/operations.rs | 21 +++++++++++++------ .../soroban-test/tests/it/integration/wrap.rs | 14 +++++++------ .../src/commands/tx/new/change_trust.rs | 4 ++-- .../src/commands/tx/new/payment.rs | 9 +++++--- .../commands/tx/new/set_trustline_flags.rs | 4 ++-- cmd/soroban-cli/src/commands/tx/op/add/mod.rs | 2 +- 6 files changed, 34 insertions(+), 20 deletions(-) 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 a733bf771..9135ae5d2 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}, @@ -267,19 +268,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 @@ -542,7 +547,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([ diff --git a/cmd/soroban-cli/src/commands/tx/new/change_trust.rs b/cmd/soroban-cli/src/commands/tx/new/change_trust.rs index d05a192d4..468291f73 100644 --- a/cmd/soroban-cli/src/commands/tx/new/change_trust.rs +++ b/cmd/soroban-cli/src/commands/tx/new/change_trust.rs @@ -23,7 +23,7 @@ pub struct Args { impl TryFrom<&Cmd> for xdr::OperationBody { type Error = tx::args::Error; fn try_from(cmd: &Cmd) -> Result { - let asset = cmd.tx.resolve_asset(&cmd.line)?; + let asset = cmd.tx.resolve_asset(&cmd.op.line)?; let line = match asset { xdr::Asset::CreditAlphanum4(asset) => xdr::ChangeTrustAsset::CreditAlphanum4(asset), xdr::Asset::CreditAlphanum12(asset) => xdr::ChangeTrustAsset::CreditAlphanum12(asset), @@ -31,7 +31,7 @@ impl TryFrom<&Cmd> for xdr::OperationBody { }; Ok(xdr::OperationBody::ChangeTrust(xdr::ChangeTrustOp { line, - limit: cmd.limit, + limit: cmd.op.limit, })) } } diff --git a/cmd/soroban-cli/src/commands/tx/new/payment.rs b/cmd/soroban-cli/src/commands/tx/new/payment.rs index d7054ed46..9544217d6 100644 --- a/cmd/soroban-cli/src/commands/tx/new/payment.rs +++ b/cmd/soroban-cli/src/commands/tx/new/payment.rs @@ -29,9 +29,12 @@ impl TryFrom<&Cmd> for xdr::OperationBody { fn try_from( Cmd { tx, - destination, - asset, - amount, + op: + Args { + destination, + asset, + amount, + }, }: &Cmd, ) -> Result { Ok(xdr::OperationBody::Payment(xdr::PaymentOp { diff --git a/cmd/soroban-cli/src/commands/tx/new/set_trustline_flags.rs b/cmd/soroban-cli/src/commands/tx/new/set_trustline_flags.rs index 4406db958..476fd1e7e 100644 --- a/cmd/soroban-cli/src/commands/tx/new/set_trustline_flags.rs +++ b/cmd/soroban-cli/src/commands/tx/new/set_trustline_flags.rs @@ -68,8 +68,8 @@ impl TryFrom<&Cmd> for xdr::OperationBody { Ok(xdr::OperationBody::SetTrustLineFlags( xdr::SetTrustLineFlagsOp { - trustor: cmd.tx.reslove_account_id(&cmd.trustor)?, - asset: cmd.tx.resolve_asset(&cmd.asset)?, + trustor: cmd.tx.reslove_account_id(&cmd.op.trustor)?, + asset: cmd.tx.resolve_asset(&cmd.op.asset)?, clear_flags, set_flags, }, diff --git a/cmd/soroban-cli/src/commands/tx/op/add/mod.rs b/cmd/soroban-cli/src/commands/tx/op/add/mod.rs index 5e69cf168..1a02d01a2 100644 --- a/cmd/soroban-cli/src/commands/tx/op/add/mod.rs +++ b/cmd/soroban-cli/src/commands/tx/op/add/mod.rs @@ -52,7 +52,7 @@ impl TryFrom<&Cmd> for OperationBody { Ok(match &cmd { Cmd::AccountMerge(account_merge::Cmd { op, .. }) => op.try_into()?, Cmd::BumpSequence(bump_sequence::Cmd { op, .. }) => op.into(), - Cmd::ChangeTrust(change_trust::Cmd { op, .. }) => op.into(), + Cmd::ChangeTrust(change_trust::Cmd { op, .. }) => op.try_into()?, Cmd::CreateAccount(create_account::Cmd { op, .. }) => op.try_into()?, Cmd::ManageData(manage_data::Cmd { op, .. }) => op.into(), Cmd::Payment(payment::Cmd { op, .. }) => op.try_into()?,