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 authored and gitbutler-client committed Nov 30, 2024
1 parent 85937c8 commit bbf8e98
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
5 changes: 2 additions & 3 deletions cmd/crates/soroban-test/tests/it/integration/hello_world.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand All @@ -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:?}]"#)));
}
Expand Down
9 changes: 4 additions & 5 deletions cmd/crates/soroban-test/tests/it/integration/keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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")
Expand All @@ -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"));
}
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 @@ -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::<builder::Asset>().unwrap(),
&format!("usdc:{test1}")
.parse::<builder::Asset>()
.unwrap()
.resolve(&locator::Args::default())
.unwrap(),
&sandbox.network_passphrase,
);
// sandbox
Expand Down Expand Up @@ -527,7 +532,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

0 comments on commit bbf8e98

Please sign in to comment.