Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal committed Apr 30, 2024
1 parent 7d655de commit 61e1c61
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
8 changes: 3 additions & 5 deletions cmd/crates/soroban-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use assert_cmd::{assert::Assert, Command};
use assert_fs::{fixture::FixtureError, prelude::PathChild, TempDir};
use fs_extra::dir::CopyOptions;

use config::network;
use config::network::{self, passphrase};

use soroban_cli::{
commands::{contract::invoke, global, keys, NetworkRunnable},
Expand All @@ -41,8 +41,6 @@ pub use wasm::Wasm;

pub const TEST_ACCOUNT: &str = "test";

pub const LOCAL_NETWORK_PASSPHRASE: &str = "Standalone Network ; February 2017";

#[derive(thiserror::Error, Debug)]
pub enum Error {
#[error(transparent)]
Expand Down Expand Up @@ -127,7 +125,7 @@ impl TestEnv {
cmd.arg(subcommand)
.env("SOROBAN_ACCOUNT", TEST_ACCOUNT)
.env("SOROBAN_RPC_URL", &self.rpc_url)
.env("SOROBAN_NETWORK_PASSPHRASE", LOCAL_NETWORK_PASSPHRASE)
.env("SOROBAN_NETWORK_PASSPHRASE", passphrase::LOCAL)
.env("XDG_CONFIG_HOME", self.temp_dir.as_os_str())
.current_dir(&self.temp_dir);
cmd
Expand Down Expand Up @@ -227,7 +225,7 @@ impl TestEnv {
let config = config::Args {
network: network::Args {
rpc_url: Some(self.rpc_url.clone()),
network_passphrase: Some(LOCAL_NETWORK_PASSPHRASE.to_string()),
network_passphrase: Some(passphrase::LOCAL.to_string()),
network: None,
},
source_account: account.to_string(),
Expand Down
12 changes: 6 additions & 6 deletions cmd/crates/soroban-test/tests/it/integration/hello_world.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use predicates::boolean::PredicateBooleanExt;
use soroban_cli::commands::{
config::{locator, secret},
contract::{self, fetch},
};

use config::{locator, network::passphrase, secret};

use soroban_cli::commands::contract::{self, fetch};
use soroban_rpc::GetLatestLedgerResponse;
use soroban_test::{AssertExt, TestEnv, LOCAL_NETWORK_PASSPHRASE};
use soroban_test::{AssertExt, TestEnv};

use crate::integration::util::extend_contract;

Expand Down Expand Up @@ -323,7 +323,7 @@ async fn fetch(sandbox: &TestEnv, id: &str) {
"--rpc-url",
&sandbox.rpc_url,
"--network-passphrase",
LOCAL_NETWORK_PASSPHRASE,
passphrase::LOCAL,
"--id",
id,
"--out-file",
Expand Down
7 changes: 4 additions & 3 deletions cmd/crates/soroban-test/tests/it/integration/wrap.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use config::network::passphrase;
use soroban_cli::utils::contract_id_hash_from_asset;
use soroban_test::{AssertExt, TestEnv, LOCAL_NETWORK_PASSPHRASE};
use soroban_test::{AssertExt, TestEnv};

#[tokio::test]
#[ignore]
async fn burn() {
let sandbox = &TestEnv::new();
let network_passphrase = LOCAL_NETWORK_PASSPHRASE.to_string();
let network_passphrase = passphrase::LOCAL;
let address = sandbox
.new_assert_cmd("keys")
.arg("address")
Expand All @@ -24,7 +25,7 @@ async fn burn() {
.success();
// wrap_cmd(&asset).run().await.unwrap();
let asset = soroban_cli::utils::parsing::parse_asset(&asset).unwrap();
let hash = contract_id_hash_from_asset(&asset, &network_passphrase).unwrap();
let hash = contract_id_hash_from_asset(&asset, network_passphrase).unwrap();
let id = stellar_strkey::Contract(hash.0).to_string();
println!("{id}, {address}");
sandbox
Expand Down
11 changes: 8 additions & 3 deletions cmd/crates/stellar-config/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,14 @@ impl Network {
let rpc_uri = Uri::from_str(&self.rpc_url)
.map_err(|_| Error::InvalidUrl(self.rpc_url.to_string()))?;
if self.network_passphrase.as_str() == passphrase::LOCAL {
let auth = rpc_uri.authority().ok_or_else(|| Error::MissingAuthority(self.rpc_url.clone()))?.clone();
let scheme = rpc_uri.scheme_str().ok_or_else(|| Error::MissingScheme(self.rpc_url.clone()))?;

let auth = rpc_uri
.authority()
.ok_or_else(|| Error::MissingAuthority(self.rpc_url.clone()))?
.clone();
let scheme = rpc_uri
.scheme_str()
.ok_or_else(|| Error::MissingScheme(self.rpc_url.clone()))?;

Ok(Uri::builder()
.authority(auth)
.scheme(scheme)
Expand Down

0 comments on commit 61e1c61

Please sign in to comment.