From a9c37da1e5ad1f1239656bb1b915bf70431532c4 Mon Sep 17 00:00:00 2001 From: Murisi Tarusenga Date: Tue, 29 Oct 2024 20:17:09 +0200 Subject: [PATCH] Sometimes use literals instead of aliases in the IBC tests. --- crates/tests/src/e2e/helpers.rs | 26 ++++++++++++++++++++++++++ crates/tests/src/e2e/ibc_tests.rs | 18 ++++++++++++------ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/crates/tests/src/e2e/helpers.rs b/crates/tests/src/e2e/helpers.rs index 47555d9205..530e392484 100644 --- a/crates/tests/src/e2e/helpers.rs +++ b/crates/tests/src/e2e/helpers.rs @@ -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; @@ -128,6 +129,31 @@ pub fn find_address(test: &Test, alias: impl AsRef) -> Result
{ Ok(address) } +/// Find the address of an account by its alias from the wallet +pub fn find_payment_address(test: &Test, alias: impl AsRef) -> Result { + 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( diff --git a/crates/tests/src/e2e/ibc_tests.rs b/crates/tests/src/e2e/ibc_tests.rs index 43b05c2143..97e591f8a2 100644 --- a/crates/tests/src/e2e/ibc_tests.rs +++ b/crates/tests/src/e2e/ibc_tests.rs @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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,