Skip to content

Commit

Permalink
Merge of #3693
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Aug 30, 2024
2 parents 40ed13a + fc002e5 commit 2e5f2da
Show file tree
Hide file tree
Showing 13 changed files with 694 additions and 2,119 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/testing/3601-clean-ibc-e2e.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Clean IBC E2E tests and refine IBC client upgrade test with Gaia
([\#3601](https://github.com/anoma/namada/issues/3601))
14 changes: 6 additions & 8 deletions .github/workflows/scripts/e2e.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"e2e::eth_bridge_tests::everything": 4,
"e2e::ibc_tests::run_ledger_ibc": 110,
"e2e::ibc_tests::run_ledger_ibc_with_hermes": 230,
"e2e::ibc_tests::pgf_over_ibc_with_hermes": 810,
"e2e::ibc_tests::proposal_ibc_token_inflation": 1100,
"e2e::ibc_tests::ibc_rate_limit": 430,
"e2e::ibc_tests::ibc_namada_gaia": 180,
"e2e::ibc_tests::ibc_upgrade_client": 550,
"e2e::ibc_tests::ibc_transfers": 414,
"e2e::ibc_tests::pgf_over_ibc": 415,
"e2e::ibc_tests::ibc_token_inflation": 840,
"e2e::ibc_tests::ibc_rate_limit": 485,
"e2e::ibc_tests::ibc_upgrade_client": 280,
"e2e::eth_bridge_tests::test_add_to_bridge_pool": 10,
"e2e::ledger_tests::double_signing_gets_slashed": 12,
"e2e::ledger_tests::ledger_many_txs_in_a_block": 55,
Expand All @@ -32,4 +30,4 @@
"e2e::wallet_tests::wallet_encrypted_key_cmds_env_var": 1,
"e2e::wallet_tests::wallet_unencrypted_key_cmds": 1,
"e2e::ledger_tests::masp_txs_and_queries": 82
}
}
4 changes: 0 additions & 4 deletions crates/test_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ pub enum TestWasms {
TxProposalCode,
TxProposalMaspRewards,
TxProposalIbcTokenInflation,
TxProposalIbcClientUpgrade,
TxReadStorageKey,
TxWriteStorageKey,
VpAlwaysFalse,
Expand Down Expand Up @@ -55,9 +54,6 @@ impl TestWasms {
TestWasms::TxProposalIbcTokenInflation => {
"tx_proposal_ibc_token_inflation.wasm"
}
TestWasms::TxProposalIbcClientUpgrade => {
"tx_proposal_ibc_client_upgrade.wasm"
}
TestWasms::TxReadStorageKey => "tx_read_storage_key.wasm",
TestWasms::TxWriteStorageKey => "tx_write.wasm",
TestWasms::VpAlwaysFalse => "vp_always_false.wasm",
Expand Down
95 changes: 47 additions & 48 deletions crates/tests/src/e2e/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ use data_encoding::HEXLOWER;
use escargot::CargoBuild;
use eyre::eyre;
use namada_apps_lib::cli::context::ENV_VAR_CHAIN_ID;
use namada_apps_lib::config::genesis::chain::DeriveEstablishedAddress;
use namada_apps_lib::config::genesis::templates;
use namada_apps_lib::config::utils::convert_tm_addr_to_socket_addr;
use namada_apps_lib::config::{Config, TendermintMode};
use namada_core::token::NATIVE_MAX_DECIMAL_PLACES;
Expand Down Expand Up @@ -179,28 +177,6 @@ pub fn get_actor_rpc(test: &Test, who: Who) -> String {
format!("http://{}:{}", socket_addr.ip(), socket_addr.port())
}

/// Get some nodes's wallet.
pub fn get_node_wallet(test: &Test, who: Who) -> Wallet<FsWalletUtils> {
let wallet_store_dir =
test.get_base_dir(who).join(test.net.chain_id.as_str());
let mut wallet = FsWalletUtils::new(wallet_store_dir);
wallet.load().expect("Failed to load wallet");
wallet
}

/// Get the public key of the validator
pub fn get_validator_pk(test: &Test, who: Who) -> Option<common::PublicKey> {
let index = match who {
Who::NonValidator => return None,
Who::Validator(i) => i,
};
let mut wallet = get_node_wallet(test, who);
let sk = wallet
.find_secret_key(format!("validator-{index}-balance-key"), None)
.ok()?;
Some(sk.ref_to())
}

/// Get a pregenesis wallet.
pub fn get_pregenesis_wallet<P: AsRef<Path>>(
base_dir_path: P,
Expand All @@ -214,30 +190,6 @@ pub fn get_pregenesis_wallet<P: AsRef<Path>>(
wallet
}

/// Get a pregenesis public key.
pub fn get_pregenesis_pk<P: AsRef<Path>>(
alias: &str,
base_dir_path: P,
) -> Option<common::PublicKey> {
let wallet = get_pregenesis_wallet(base_dir_path);
wallet.find_public_key(alias).ok()
}

/// Get a pregenesis public key.
pub fn get_established_addr_from_pregenesis<P: AsRef<Path>>(
alias: &str,
base_dir_path: P,
genesis: &templates::All<templates::Unvalidated>,
) -> Option<Address> {
let pk = get_pregenesis_pk(alias, base_dir_path)?;
let established_accounts =
genesis.transactions.established_account.as_ref()?;
let acct = established_accounts.iter().find(|&acct| {
acct.public_keys.len() == 1 && acct.public_keys[0].raw == pk
})?;
Some(acct.derive_address())
}

/// Find the address of an account by its alias from the wallet
#[allow(dead_code)]
pub fn find_keypair(
Expand Down Expand Up @@ -660,6 +612,7 @@ fn make_hermes_chain_config_for_gaia(test: &Test) -> Value {
Value::String(key_dir.to_string_lossy().to_string()),
);
chain.insert("store_prefix".to_owned(), Value::String("ibc".to_owned()));
chain.insert("gas_multiplier".to_owned(), Value::Float(1.3));
let mut table = toml::map::Map::new();
table.insert("price".to_owned(), Value::Float(0.001));
table.insert("denom".to_owned(), Value::String("stake".to_string()));
Expand Down Expand Up @@ -707,6 +660,44 @@ pub fn update_gaia_config(test: &Test) -> Result<()> {
file.write_all(values.to_string().as_bytes())
.map_err(|e| eyre!(format!("Writing a Gaia app.toml failed: {}", e)))?;

let genesis_path = test.test_dir.as_ref().join("gaia/config/genesis.json");
let s = std::fs::read_to_string(&genesis_path)
.expect("Reading Gaia genesis.json failed");
let mut genesis: serde_json::Value =
serde_json::from_str(&s).expect("Decoding Gaia genesis.json failed");
// gas
if let Some(min_base_gas_price) =
genesis.pointer_mut("/app_state/feemarket/params/min_base_gas_price")
{
*min_base_gas_price =
serde_json::Value::String("0.000000000000000001".to_string());
}
if let Some(base_gas_price) =
genesis.pointer_mut("/app_state/feemarket/state/base_gas_price")
{
*base_gas_price =
serde_json::Value::String("0.000000000000000001".to_string());
}
// gov
if let Some(max_deposit_period) =
genesis.pointer_mut("/app_state/gov/params/max_deposit_period")
{
*max_deposit_period = serde_json::Value::String("10s".to_string());
}
if let Some(voting_period) =
genesis.pointer_mut("/app_state/gov/params/voting_period")
{
*voting_period = serde_json::Value::String("10s".to_string());
}

let file = OpenOptions::new()
.write(true)
.truncate(true)
.open(&genesis_path)?;
let writer = std::io::BufWriter::new(file);
serde_json::to_writer_pretty(writer, &genesis)
.expect("Writing Gaia genesis.toml failed");

Ok(())
}

Expand All @@ -727,3 +718,11 @@ pub fn find_gaia_address(

Ok(matched.trim().to_string())
}

pub fn get_gaia_gov_address(test: &Test) -> Result<String> {
let args = ["query", "auth", "module-account", "gov"];
let mut gaia = run_gaia_cmd(test, args, Some(40))?;
let (_, matched) = gaia.exp_regex("cosmos[a-z0-9]+")?;

Ok(matched.trim().to_string())
}
Loading

0 comments on commit 2e5f2da

Please sign in to comment.