Skip to content

Commit

Permalink
Run bootstrap test with connection and channel handshake
Browse files Browse the repository at this point in the history
  • Loading branch information
soareschen committed Jan 9, 2024
1 parent aa37f29 commit e5a4fc2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
38 changes: 36 additions & 2 deletions crates/cosmos/cosmos-integration-tests/src/tests/bootstrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ use core::time::Duration;
use std::sync::Arc;

use eyre::Error;
use hermes_cosmos_client_components::types::channel::CosmosInitChannelOptions;
use hermes_cosmos_relayer::contexts::builder::CosmosBuilder;
use hermes_cosmos_relayer::contexts::relay::CosmosRelay;
use hermes_relayer_components::build::traits::components::relay_from_chains_builder::CanBuildRelayFromChains;
use hermes_relayer_components::build::traits::target::relay::RelayAToBTarget;
use hermes_relayer_components::relay::impls::channel::bootstrap::CanBootstrapChannel;
use hermes_relayer_components::relay::impls::connection::bootstrap::CanBootstrapConnection;
use hermes_relayer_components::relay::traits::components::client_creator::CanCreateClient;
use hermes_relayer_components::relay::traits::target::{DestinationTarget, SourceTarget};
use hermes_relayer_runtime::types::runtime::HermesRuntime;
use hermes_test_components::bootstrap::traits::chain::CanBootstrapChain;
use ibc_relayer::chain::client::ClientSettings;
use ibc_relayer::foreign_client::CreateOptions;
use ibc_relayer_types::core::ics24_host::identifier::PortId;
use tokio::runtime::Runtime;
use tokio::test;
use tokio::time::sleep;
Expand Down Expand Up @@ -42,7 +48,7 @@ async fn test_bootstrap_cosmos_chain() -> Result<(), Error> {

sleep(Duration::from_secs(2)).await;

let _client_a_to_b_id = CosmosRelay::create_client(
let client_id_a = CosmosRelay::create_client(
SourceTarget,
&chain_a.base_chain,
&chain_b.base_chain,
Expand All @@ -54,7 +60,7 @@ async fn test_bootstrap_cosmos_chain() -> Result<(), Error> {
)
.await?;

let _client_b_to_a_id = CosmosRelay::create_client(
let client_id_b = CosmosRelay::create_client(
DestinationTarget,
&chain_b.base_chain,
&chain_a.base_chain,
Expand All @@ -66,5 +72,33 @@ async fn test_bootstrap_cosmos_chain() -> Result<(), Error> {
)
.await?;

let relay = bootstrap
.builder
.build_relay_from_chains(
RelayAToBTarget,
&client_id_a,
&client_id_b,
chain_a.base_chain.clone(),
chain_b.base_chain.clone(),
)
.await?;

let (connection_id_a, _connection_id_b) =
relay.bootstrap_connection(&Default::default()).await?;

let init_channel_option = CosmosInitChannelOptions {
ordering: Default::default(),
connection_hops: vec![connection_id_a],
channel_version: Default::default(),
};

relay
.bootstrap_channel(
&PortId::transfer(),
&PortId::transfer(),
&init_channel_option,
)
.await?;

Ok(())
}
2 changes: 1 addition & 1 deletion crates/cosmos/cosmos-relayer/src/contexts/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl CosmosBuilder {
BaseError::spawn(SpawnError::missing_chain_config(chain_id.clone()))
})?;

self.build_chain_with_config(chain_config, self.key_map.get(&chain_id))
self.build_chain_with_config(chain_config, self.key_map.get(chain_id))
.await
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ where
// Wait for a while and check if the child process exited immediately.
// If so, return error since we expect the child process to be running in the background.

runtime.sleep(Duration::from_millis(500)).await;
runtime.sleep(Duration::from_secs(1)).await;

let status = child_process.try_wait().map_err(Runtime::raise_error)?;

Expand Down

0 comments on commit e5a4fc2

Please sign in to comment.