Skip to content

Commit

Permalink
Sometimes use literals instead of aliases in the IBC tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
murisi committed Oct 29, 2024
1 parent 7748a05 commit a9c37da
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
26 changes: 26 additions & 0 deletions crates/tests/src/e2e/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use eyre::eyre;
use namada_apps_lib::cli::context::ENV_VAR_CHAIN_ID;
use namada_apps_lib::config::utils::convert_tm_addr_to_socket_addr;
use namada_apps_lib::config::{Config, TendermintMode};
use namada_core::masp::PaymentAddress;
use namada_core::token::NATIVE_MAX_DECIMAL_PLACES;
use namada_sdk::address::Address;
use namada_sdk::chain::Epoch;
Expand Down Expand Up @@ -128,6 +129,31 @@ pub fn find_address(test: &Test, alias: impl AsRef<str>) -> Result<Address> {
Ok(address)
}

/// Find the address of an account by its alias from the wallet
pub fn find_payment_address(test: &Test, alias: impl AsRef<str>) -> Result<PaymentAddress> {
let mut find = run!(
test,
Bin::Wallet,
&["find", "--addr", "--alias", alias.as_ref()],
Some(10)
)?;
find.exp_string("Found payment address:")?;
let (unread, matched) = find.exp_regex("\".*\": .*")?;
let address_str = strip_trailing_newline(&matched)
.trim()
.rsplit_once(' ')
.unwrap()
.1;
let address = PaymentAddress::from_str(address_str).map_err(|e| {
eyre!(format!(
"Address: {} parsed from {}, Error: {}\n\nOutput: {}",
address_str, matched, e, unread
))
})?;
println!("Found {}", address);
Ok(address)
}

/// Find the balance of specific token for an account.
#[allow(dead_code)]
pub fn find_balance(
Expand Down
18 changes: 12 additions & 6 deletions crates/tests/src/e2e/ibc_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ use sha2::{Digest, Sha256};

use crate::e2e::helpers::{
epoch_sleep, epochs_per_year_from_min_duration, find_address,
find_gaia_address, get_actor_rpc, get_epoch, get_gaia_gov_address,
find_gaia_address, find_payment_address, get_actor_rpc, get_epoch,
get_gaia_gov_address,
};
use crate::e2e::ledger_tests::{
start_namada_ledger_node_wait_wasm, write_json_file,
Expand Down Expand Up @@ -209,10 +210,11 @@ fn ibc_transfers() -> Result<()> {
&port_id_namada,
&channel_id_namada,
)?;
let masp_receiver = find_payment_address(&test, AA_PAYMENT_ADDRESS)?.to_string();
transfer_from_gaia(
&test_gaia,
GAIA_USER,
AA_PAYMENT_ADDRESS,
masp_receiver.clone(),
GAIA_COIN,
100,
&port_id_gaia,
Expand Down Expand Up @@ -268,10 +270,11 @@ fn ibc_transfers() -> Result<()> {
&port_id_namada,
&channel_id_namada,
)?;
let masp_receiver = find_payment_address(&test, AA_PAYMENT_ADDRESS)?.to_string();
transfer_from_gaia(
&test_gaia,
GAIA_USER,
AA_PAYMENT_ADDRESS,
masp_receiver,
get_gaia_denom_hash(&ibc_denom_on_gaia),
1_000_000,
&port_id_gaia,
Expand Down Expand Up @@ -395,10 +398,11 @@ fn ibc_transfers() -> Result<()> {
check_gaia_balance(&test_gaia, GAIA_USER, GAIA_COIN, 810)?;

// Missing memo
let masp_receiver = find_payment_address(&test, AA_PAYMENT_ADDRESS)?.to_string();
transfer_from_gaia(
&test_gaia,
GAIA_USER,
AA_PAYMENT_ADDRESS,
masp_receiver,
GAIA_COIN,
100,
&port_id_gaia,
Expand All @@ -421,10 +425,11 @@ fn ibc_transfers() -> Result<()> {
&port_id_namada,
&channel_id_namada,
)?;
let masp_receiver = find_payment_address(&test, AA_PAYMENT_ADDRESS)?.to_string();
transfer_from_gaia(
&test_gaia,
GAIA_USER,
AA_PAYMENT_ADDRESS,
masp_receiver,
GAIA_COIN,
101,
&port_id_gaia,
Expand Down Expand Up @@ -699,10 +704,11 @@ fn ibc_token_inflation() -> Result<()> {
&port_id_namada,
&channel_id_namada,
)?;
let masp_receiver = find_payment_address(&test, AA_PAYMENT_ADDRESS)?.to_string();
transfer_from_gaia(
&test_gaia,
GAIA_USER,
AA_PAYMENT_ADDRESS,
masp_receiver,
GAIA_COIN,
1,
&port_id_gaia,
Expand Down

0 comments on commit a9c37da

Please sign in to comment.