Skip to content

Commit

Permalink
Merge branch 'yuji/ibc-namada-gaia-e2e' (#2818)
Browse files Browse the repository at this point in the history
* yuji/ibc-namada-gaia-e2e:
  fix for gaia v15
  fix e2e tests
  change the rate limit
  add changelog
  add IBC e2e test with Gaia
  install gaiad for e2e tests
  Rounds epoch_length in localnet script to prevent generating a float
  scripts: add merge_pr.sh
  add backslash
  fixing command to generate localnet files on readme
  • Loading branch information
brentstone committed Apr 30, 2024
2 parents bfc03ec + 260dbe0 commit b32ae66
Show file tree
Hide file tree
Showing 10 changed files with 683 additions and 137 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/testing/2232-ibc-namada-gaia-e2e.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Add IBC E2E test with Gaia
([\#2232](https://github.com/anoma/namada/issues/2232))
7 changes: 7 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,12 @@ jobs:
curl -o hermes.zip -LO https://github.com/heliaxdev/hermes/releases/download/v${HERMES_VERSION}/hermes-v${HERMES_VERSION}-x86_64-unknown-linux-gnu.zip
unzip hermes.zip
mv hermes /usr/local/bin
- name: Download Gaia
run: |
GAIA_VERSION=$(cat .github/workflows/scripts/gaia.txt)
echo "Using gaiad version: ${GAIA_VERSION}"
curl -o gaiad -LO https://github.com/cosmos/gaia/releases/download/v${GAIA_VERSION}/gaiad-v${GAIA_VERSION}-linux-amd64
mv gaiad /usr/local/bin
- name: Change permissions
run: |
chmod +x target/release/namada
Expand All @@ -684,6 +690,7 @@ jobs:
chmod +x target/release/namadar
chmod +x /usr/local/bin/cometbft
chmod +x /usr/local/bin/hermes
chmod +x /usr/local/bin/gaiad
- name: Run e2e test
run: python3 .github/workflows/scripts/schedule-e2e.py
env:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/scripts/e2e.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"e2e::ibc_tests::pgf_over_ibc_with_hermes": 240,
"e2e::ibc_tests::proposal_ibc_token_inflation": 600,
"e2e::ibc_tests::ibc_rate_limit": 500,
"e2e::ibc_tests::ibc_namada_gaia": 450,
"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 @@ -28,4 +29,4 @@
"e2e::wallet_tests::wallet_encrypted_key_cmds": 1,
"e2e::wallet_tests::wallet_encrypted_key_cmds_env_var": 1,
"e2e::wallet_tests::wallet_unencrypted_key_cmds": 1
}
}
1 change: 1 addition & 0 deletions .github/workflows/scripts/gaia.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
15.2.0
114 changes: 110 additions & 4 deletions crates/tests/src/e2e/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! E2E test helpers

use std::fs::File;
use std::fs::{File, OpenOptions};
use std::future::Future;
use std::io::Write;
use std::path::Path;
Expand Down Expand Up @@ -32,10 +32,10 @@ use namada_sdk::wallet::Wallet;
use toml::Value;

use super::setup::{
self, sleep, NamadaBgCmd, NamadaCmd, Test, ENV_VAR_DEBUG,
self, run_gaia_cmd, sleep, NamadaBgCmd, NamadaCmd, Test, ENV_VAR_DEBUG,
ENV_VAR_USE_PREBUILT_BINARIES,
};
use crate::e2e::setup::{Bin, Who, APPS_PACKAGE};
use crate::e2e::setup::{constants, Bin, Who, APPS_PACKAGE};
use crate::strings::{LEDGER_STARTED, TX_APPLIED_SUCCESS};
use crate::{run, run_as};

Expand Down Expand Up @@ -552,7 +552,11 @@ pub fn make_hermes_config(test_a: &Test, test_b: &Test) -> Result<()> {

let chains = vec![
make_hermes_chain_config(test_a),
make_hermes_chain_config(test_b),
if test_b.net.chain_id.to_string() == constants::GAIA_CHAIN_ID {
make_hermes_chain_config_for_gaia(test_b)
} else {
make_hermes_chain_config(test_b)
},
];

config.insert("chains".to_owned(), Value::Array(chains));
Expand Down Expand Up @@ -618,3 +622,105 @@ fn make_hermes_chain_config(test: &Test) -> Value {

Value::Table(chain)
}

fn make_hermes_chain_config_for_gaia(test: &Test) -> Value {
let mut table = toml::map::Map::new();
table.insert("mode".to_owned(), Value::String("push".to_owned()));
let url = format!("ws://{}/websocket", setup::constants::GAIA_RPC);
table.insert("url".to_owned(), Value::String(url));
table.insert("batch_delay".to_owned(), Value::String("500ms".to_owned()));
let event_source = Value::Table(table);

let mut chain = toml::map::Map::new();
chain.insert("id".to_owned(), Value::String("gaia".to_string()));
chain.insert("type".to_owned(), Value::String("CosmosSdk".to_owned()));
chain.insert(
"rpc_addr".to_owned(),
Value::String(format!("http://{}", setup::constants::GAIA_RPC)),
);
chain.insert(
"grpc_addr".to_owned(),
Value::String("http://127.0.0.1:9090".to_owned()),
);
chain.insert("event_source".to_owned(), event_source);
chain.insert(
"account_prefix".to_owned(),
Value::String("cosmos".to_owned()),
);
chain.insert(
"key_name".to_owned(),
Value::String(setup::constants::GAIA_RELAYER.to_string()),
);
let key_dir = test.test_dir.as_ref().join("hermes/keys");
chain.insert(
"key_store_folder".to_owned(),
Value::String(key_dir.to_string_lossy().to_string()),
);
chain.insert("store_prefix".to_owned(), Value::String("ibc".to_owned()));
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()));
chain.insert("gas_price".to_owned(), Value::Table(table));

Value::Table(chain)
}

pub fn update_gaia_config(test: &Test) -> Result<()> {
let config_path = test.test_dir.as_ref().join("gaia/config/config.toml");
let s = std::fs::read_to_string(&config_path)
.expect("Reading Gaia config failed");
let mut values = s
.parse::<toml::Value>()
.expect("Parsing Gaia config failed");
if let Some(consensus) = values.get_mut("consensus") {
if let Some(timeout_commit) = consensus.get_mut("timeout_commit") {
*timeout_commit = "1s".into();
}
if let Some(timeout_propose) = consensus.get_mut("timeout_propose") {
*timeout_propose = "1s".into();
}
}
let mut file = OpenOptions::new()
.write(true)
.truncate(true)
.open(&config_path)?;
file.write_all(values.to_string().as_bytes()).map_err(|e| {
eyre!(format!("Writing a Gaia config file failed: {}", e))
})?;

let app_path = test.test_dir.as_ref().join("gaia/config/app.toml");
let s = std::fs::read_to_string(&app_path)
.expect("Reading Gaia app.toml failed");
let mut values = s
.parse::<toml::Value>()
.expect("Parsing Gaia app.toml failed");
if let Some(mininum_gas_prices) = values.get_mut("minimum-gas-prices") {
*mininum_gas_prices = "0.0001stake".into();
}
let mut file = OpenOptions::new()
.write(true)
.truncate(true)
.open(&app_path)?;
file.write_all(values.to_string().as_bytes())
.map_err(|e| eyre!(format!("Writing a Gaia app.toml failed: {}", e)))?;

Ok(())
}

pub fn find_gaia_address(
test: &Test,
alias: impl AsRef<str>,
) -> Result<String> {
let args = [
"keys",
"--keyring-backend",
"test",
"show",
alias.as_ref(),
"-a",
];
let mut gaia = run_gaia_cmd(test, args, Some(40))?;
let (_, matched) = gaia.exp_regex("cosmos.*")?;

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

0 comments on commit b32ae66

Please sign in to comment.