Skip to content

Commit

Permalink
fix: add test and fix others
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed Dec 6, 2024
1 parent 54ad073 commit 69fc190
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 20 deletions.
21 changes: 15 additions & 6 deletions cmd/crates/soroban-test/tests/it/integration/tx/operations.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use soroban_cli::{
config::locator,
tx::{builder, ONE_XLM},
utils::contract_id_hash_from_asset,
xdr::{self, ReadXdr, SequenceNumber},
Expand Down Expand Up @@ -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::<builder::Asset>().unwrap(),
&format!("usdc:{test1}")
.parse::<builder::Asset>()
.unwrap()
.resolve(&locator::Args::default())
.unwrap(),
&sandbox.network_passphrase,
);
// sandbox
Expand Down Expand Up @@ -542,7 +547,11 @@ async fn change_trust() {

// wrap_cmd(&asset).run().await.unwrap();
let id = contract_id_hash_from_asset(
asset.parse::<builder::Asset>().unwrap(),
&asset
.parse::<builder::Asset>()
.unwrap()
.resolve(&locator::Args::default())
.unwrap(),
&sandbox.network_passphrase,
);
sandbox
Expand Down
14 changes: 8 additions & 6 deletions cmd/crates/soroban-test/tests/it/integration/wrap.rs
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -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::<builder::Asset>()
.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([
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/commands/tx/new/change_trust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ pub struct Args {
impl TryFrom<&Cmd> for xdr::OperationBody {
type Error = tx::args::Error;
fn try_from(cmd: &Cmd) -> Result<Self, Self::Error> {
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),
xdr::Asset::Native => xdr::ChangeTrustAsset::Native,
};
Ok(xdr::OperationBody::ChangeTrust(xdr::ChangeTrustOp {
line,
limit: cmd.limit,
limit: cmd.op.limit,
}))
}
}
9 changes: 6 additions & 3 deletions cmd/soroban-cli/src/commands/tx/new/payment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self, Self::Error> {
Ok(xdr::OperationBody::Payment(xdr::PaymentOp {
Expand Down
4 changes: 2 additions & 2 deletions cmd/soroban-cli/src/commands/tx/new/set_trustline_flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/soroban-cli/src/commands/tx/op/add/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()?,
Expand Down

0 comments on commit 69fc190

Please sign in to comment.