Skip to content

Commit

Permalink
WIP: fixing integration test with Namada
Browse files Browse the repository at this point in the history
  • Loading branch information
yito88 committed Jun 12, 2024
1 parent 90113e8 commit a3e7d13
Show file tree
Hide file tree
Showing 17 changed files with 241 additions and 113 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions tools/integration-test/src/tests/client_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use ibc_relayer::foreign_client::CreateOptions;
use ibc_relayer::object::ObjectType;
use ibc_relayer_types::clients::ics07_tendermint::client_state::ClientState as TmClientState;

use ibc_test_framework::chain::config;
use ibc_test_framework::prelude::*;

struct ClientFilterBlocksConnectionTest;
Expand Down Expand Up @@ -75,11 +74,6 @@ impl TestOverrides for ClientFilterAllowsConnectionTest {
trust_threshold: Some(TrustThreshold::ONE_THIRD),
}
}

fn namada_modify_parameter_file(&self, parameter: &mut toml::Value) -> Result<(), Error> {
config::namada::set_pipeline_len(parameter, 120001)?;
Ok(())
}
}

impl BinaryChannelTest for ClientFilterBlocksConnectionTest {
Expand Down
3 changes: 2 additions & 1 deletion tools/integration-test/src/tests/client_refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ fn test_client_default_refresh() -> Result<(), Error> {
run_binary_chain_test(&ClientDefaultsTest)
}

#[test]
// TODO: it should work after surrpoting gas estimation
#[cfg(not(feature = "namada"))]
#[test]
fn test_client_fail_refresh() -> Result<(), Error> {
run_binary_chain_test(&ClientFailsTest)
}
Expand Down
6 changes: 2 additions & 4 deletions tools/integration-test/src/tests/client_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,21 @@ struct ClientOptionsTest;
impl TestOverrides for ClientDefaultsTest {
fn modify_relayer_config(&self, config: &mut Config) {
match &mut config.chains[0] {
ChainConfig::CosmosSdk(chain_config_a) => {
ChainConfig::CosmosSdk(chain_config_a) | ChainConfig::Namada(chain_config_a) => {
chain_config_a.clock_drift = Duration::from_secs(3);
chain_config_a.max_block_time = Duration::from_secs(5);
chain_config_a.trusting_period = Some(Duration::from_secs(120_000));
chain_config_a.trust_threshold = TrustThreshold::new(13, 23).unwrap();
}
ChainConfig::Namada(_) => {}
}

match &mut config.chains[1] {
ChainConfig::CosmosSdk(chain_config_b) => {
ChainConfig::CosmosSdk(chain_config_b) | ChainConfig::Namada(chain_config_b) => {
chain_config_b.clock_drift = Duration::from_secs(6);
chain_config_b.max_block_time = Duration::from_secs(15);
chain_config_b.trusting_period = Some(Duration::from_secs(340_000));
chain_config_b.trust_threshold = TrustThreshold::TWO_THIRDS;
}
ChainConfig::Namada(_) => {}
}
}
}
Expand Down
60 changes: 35 additions & 25 deletions tools/integration-test/src/tests/consensus_states.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
use ibc_relayer::chain::{
cosmos::query::consensus_state::query_consensus_states,
requests::{PageRequest, QueryConsensusStateHeightsRequest, QueryConsensusStatesRequest},
use ibc_relayer::{
chain::{
cosmos::query::consensus_state::query_consensus_states,
requests::{PageRequest, QueryConsensusStateHeightsRequest, QueryConsensusStatesRequest},
},
config::ChainConfig,
};

use ibc_test_framework::prelude::*;
use ibc_test_framework::util::namada;

#[test]
fn test_consensus_state_heights() -> Result<(), Error> {
Expand Down Expand Up @@ -48,29 +52,35 @@ impl BinaryChainTest for ConsensusStateHeights {
&CONSENSUS_STATES_COUNT,
)?;

let grpc_address = chains
.node_b
.value()
.chain_driver
.grpc_address()
.as_str()
.parse()
.unwrap();
let states = match chains.handle_b().config().expect("Config should exist") {
ChainConfig::Namada(config) => chains.node_b.value().chain_driver.runtime.block_on(
namada::query_consensus_states(config.rpc_addr, *chains.client_id_b().value()),
)?,
_ => {
let grpc_address = chains
.node_b
.value()
.chain_driver
.grpc_address()
.as_str()
.parse()
.unwrap();

let states =
chains
.node_b
.value()
.chain_driver
.runtime
.block_on(query_consensus_states(
chains.node_b.chain_id().value(),
&grpc_address,
QueryConsensusStatesRequest {
client_id: (*chains.client_id_b().value()).clone(),
pagination: Some(PageRequest::all()),
},
))?;
chains
.node_b
.value()
.chain_driver
.runtime
.block_on(query_consensus_states(
chains.node_b.chain_id().value(),
&grpc_address,
QueryConsensusStatesRequest {
client_id: (*chains.client_id_b().value()).clone(),
pagination: Some(PageRequest::all()),
},
))?
}
};

assert_eq(
"did not find the expected number of consensus states",
Expand Down
3 changes: 2 additions & 1 deletion tools/integration-test/src/tests/denom_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ impl BinaryChannelTest for IbcDenomTraceTest {
assert_eq(
"Denom returned by denom_trace query should be the same as denom_a",
&denom_trace.base_denom,
&denom_a.value().as_str().to_string(),
// check the raw address
&denom_a.value().hash_only(),
)?;

Ok(())
Expand Down
2 changes: 2 additions & 0 deletions tools/integration-test/src/tests/error_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use ibc_relayer_types::events::IbcEvent;
use ibc_test_framework::prelude::*;
use ibc_test_framework::relayer::transfer::build_transfer_message;

// TODO: Need to fix Namada and Namada event checking
#[cfg(not(feature = "namada"))]
#[test]
fn test_error_events() -> Result<(), Error> {
run_binary_channel_test(&ErrorEventsTest)
Expand Down
3 changes: 0 additions & 3 deletions tools/integration-test/src/tests/handshake_on_start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use ibc_test_framework::{
},
};

#[cfg(not(feature = "namada"))]
#[test]
fn test_connection_open_handshake() -> Result<(), Error> {
run_binary_chain_test(&ConnectionOpenHandshake {
Expand All @@ -27,7 +26,6 @@ fn test_connection_open_handshake_no_worker() -> Result<(), Error> {
})
}

#[cfg(not(feature = "namada"))]
#[test]
fn test_connection_try_handshake() -> Result<(), Error> {
run_binary_chain_test(&ConnectionTryHandshake {
Expand Down Expand Up @@ -98,7 +96,6 @@ fn test_channel_ack_handshake_no_worker() -> Result<(), Error> {
})
}

#[cfg(not(feature = "namada"))]
#[test]
fn test_channel_optimistic_handshake() -> Result<(), Error> {
run_binary_chain_test(&OptimisticChannelOpenHandshake {})
Expand Down
1 change: 0 additions & 1 deletion tools/integration-test/src/tests/ics20_filter/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
#[cfg(not(feature = "namada"))]
pub mod memo;
13 changes: 1 addition & 12 deletions tools/integration-test/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,26 @@
will pick up the definition by default.
*/

#[cfg(not(feature = "namada"))]
pub mod clear_packet;
#[cfg(not(feature = "namada"))]
pub mod client_expiration;
#[cfg(not(feature = "namada"))]
pub mod client_filter;
pub mod client_refresh;
#[cfg(not(feature = "namada"))]
pub mod client_settings;
#[cfg(not(any(feature = "celestia", feature = "namada")))]
pub mod client_upgrade;
pub mod connection_delay;
#[cfg(not(feature = "namada"))]
pub mod consensus_states;
#[cfg(not(feature = "namada"))]
pub mod denom_trace;
#[cfg(not(feature = "namada"))]
pub mod error_events;
pub mod execute_schedule;
pub mod handshake_on_start;
pub mod ics20_filter;
#[cfg(not(feature = "namada"))]
pub mod memo;
#[cfg(not(feature = "namada"))]
pub mod python;
pub mod query_packet;
#[cfg(not(feature = "namada"))]
pub mod supervisor;
#[cfg(not(feature = "namada"))]
pub mod tendermint;
#[cfg(not(any(feature = "celestia", feature = "namada")))]
#[cfg(not(any(feature = "celestia")))]
pub mod ternary_transfer;
pub mod transfer;

Expand Down
2 changes: 2 additions & 0 deletions tools/test-framework/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ ibc-relayer-types = { workspace = true }
ibc-relayer = { workspace = true }
ibc-relayer-cli = { workspace = true }
ibc-proto = { workspace = true, features = ["serde"] }
namada_ibc = { workspace = true }
namada_sdk = { workspace = true }
tendermint-rpc = { workspace = true, features = ["http-client", "websocket-client"] }

color-eyre = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion tools/test-framework/src/bootstrap/namada.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ fn add_namada_key(
.find_address(address_name)
.ok_or_else(|| eyre!("error loading the address from Namada wallet"))?;
let namada_key = NamadaKeyPair {
alias: key_name.to_string(),
alias: address_name.to_string(),
address: address.into_owned(),
secret_key: secret_key.clone(),
};
Expand Down
8 changes: 4 additions & 4 deletions tools/test-framework/src/chain/cli/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,18 @@ pub fn query_namada_balance(
)?;

let words: Vec<&str> = output.stdout.split_whitespace().collect();
let denom_hash = &format!("{}:", denom.hash_only());
let raw_addr = &format!("{}:", denom.hash_only());

if let Some(derived_index) = words.iter().position(|&w| w.contains(denom_hash)) {
if let Some(derived_index) = words.iter().position(|&w| w.contains(raw_addr)) {
if let Some(&amount_str) = words.get(derived_index + 1) {
return Amount::from_str(amount_str).map_err(handle_generic_error);
}
Err(Error::generic(eyre!(
"chain id is not 1 words after `{denom_hash}`: raw output `{}` split output `{words:#?}`",
"chain id is not 1 words after `{raw_addr}`: raw output `{}` split output `{words:#?}`",
output.stdout
)))
} else {
let denom_display_name = &format!("{}:", denom.display_name());
let denom_display_name = &format!("{}:", denom.namada_display_name());
if let Some(derived_index) = words.iter().position(|&w| w.contains(denom_display_name)) {
if let Some(&amount_str) = words.get(derived_index + 1) {
return Amount::from_str(amount_str).map_err(handle_generic_error);
Expand Down
Loading

0 comments on commit a3e7d13

Please sign in to comment.