From 6d3db183b8307cadb3b0bdb21acb0d9888715430 Mon Sep 17 00:00:00 2001 From: Soares Chen Date: Mon, 10 Jul 2023 08:22:06 +0200 Subject: [PATCH] Minor touch up --- .../src/chain/traits/types/channel.rs | 2 +- .../src/relay/impls/channel/open_ack.rs | 2 +- .../src/relay/impls/channel/open_confirm.rs | 2 +- .../src/relay/impls/channel/open_handshake.rs | 2 +- .../src/relay/impls/channel/open_try.rs | 2 +- .../src/tests/next/connection.rs | 38 +++++++++++-------- 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/crates/relayer-components/src/chain/traits/types/channel.rs b/crates/relayer-components/src/chain/traits/types/channel.rs index 471ee7d06a..e20c09098d 100644 --- a/crates/relayer-components/src/chain/traits/types/channel.rs +++ b/crates/relayer-components/src/chain/traits/types/channel.rs @@ -7,7 +7,7 @@ pub trait HasInitChannelOptionsType: HasIbcChainTypes: HasIbcChainTypes { type ChannelOpenTryPayload: Async; diff --git a/crates/relayer-components/src/relay/impls/channel/open_ack.rs b/crates/relayer-components/src/relay/impls/channel/open_ack.rs index c6d671f41b..8419a58190 100644 --- a/crates/relayer-components/src/relay/impls/channel/open_ack.rs +++ b/crates/relayer-components/src/relay/impls/channel/open_ack.rs @@ -20,7 +20,7 @@ use crate::std_prelude::*; This implements the `ChanOpenAck` step of the IBC channel handshake protocol. - Note that this implementation does not check that the connection exists on + Note that this implementation does not check that the channel exists on the destination chain. It also doesn't check that the channel end at the destination chain is really in the `OPEN_TRY` state. This will be implemented as a separate wrapper component. (TODO) diff --git a/crates/relayer-components/src/relay/impls/channel/open_confirm.rs b/crates/relayer-components/src/relay/impls/channel/open_confirm.rs index bc0ce83dcc..64ef17b4aa 100644 --- a/crates/relayer-components/src/relay/impls/channel/open_confirm.rs +++ b/crates/relayer-components/src/relay/impls/channel/open_confirm.rs @@ -20,7 +20,7 @@ use crate::std_prelude::*; This implements the `ChanOpenConfirm` step of the IBC channel handshake protocol. - Note that this implementation does not check that the connection exists on + Note that this implementation does not check that the channel exists on the destination chain, that a channel exists on the source chain, and that the channel end at the source chain is really in the `OPEN` state. This will be implemented as a separate wrapper component. (TODO) diff --git a/crates/relayer-components/src/relay/impls/channel/open_handshake.rs b/crates/relayer-components/src/relay/impls/channel/open_handshake.rs index a36eb96d67..46365d7de1 100644 --- a/crates/relayer-components/src/relay/impls/channel/open_handshake.rs +++ b/crates/relayer-components/src/relay/impls/channel/open_handshake.rs @@ -9,7 +9,7 @@ use crate::relay::traits::channel::open_try::CanRelayChannelOpenTry; use crate::std_prelude::*; /** - Relays a connection open handshake using a channel ID that has been + Relays a channel open handshake using a channel ID that has been initialized at the source chain, and the port IDs used. Specifically, the `ChanOpenTry`, `ChanOpenAck`, and `ChanOpenConfirm` steps of diff --git a/crates/relayer-components/src/relay/impls/channel/open_try.rs b/crates/relayer-components/src/relay/impls/channel/open_try.rs index 60e040ce2b..231b03c11e 100644 --- a/crates/relayer-components/src/relay/impls/channel/open_try.rs +++ b/crates/relayer-components/src/relay/impls/channel/open_try.rs @@ -29,7 +29,7 @@ pub trait InjectMissingChannelTryEventError: HasRelayChains { This implements the `ChanOpenTry` step of the IBC channel handshake protocol. - Note that this implementation does not check that the connection exists on + Note that this implementation does not check that the channel exists on the destination chain. It also doesn't check that the channel end at the source chain is really in the `OPEN_INIT` state. This will be implemented as a separate wrapper component. (TODO) diff --git a/tools/integration-test/src/tests/next/connection.rs b/tools/integration-test/src/tests/next/connection.rs index 4c01e73aca..382411333b 100644 --- a/tools/integration-test/src/tests/next/connection.rs +++ b/tools/integration-test/src/tests/next/connection.rs @@ -7,24 +7,25 @@ use ibc_relayer_components::relay::impls::channel::bootstrap::CanBootstrapChanne use ibc_relayer_components::relay::impls::connection::bootstrap::CanBootstrapConnection; use ibc_relayer_components::relay::traits::two_way::HasTwoWayRelay; use ibc_relayer_cosmos::types::channel::CosmosInitChannelOptions; +use ibc_relayer_cosmos::types::error::Error as CosmosError; use ibc_test_framework::prelude::*; use crate::tests::next::context::new_cosmos_builder; #[test] -fn test_connection_handshake_next() -> Result<(), Error> { - run_binary_chain_test(&ConnectionHandshakeTest) +fn test_connection_and_channel_handshake_next() -> Result<(), Error> { + run_binary_chain_test(&ConnectionAndChannelHandshakeTest) } -pub struct ConnectionHandshakeTest; +pub struct ConnectionAndChannelHandshakeTest; -impl TestOverrides for ConnectionHandshakeTest { +impl TestOverrides for ConnectionAndChannelHandshakeTest { fn should_spawn_supervisor(&self) -> bool { false } } -impl BinaryChainTest for ConnectionHandshakeTest { +impl BinaryChainTest for ConnectionAndChannelHandshakeTest { fn run( &self, _config: &TestConfig, @@ -47,39 +48,46 @@ impl BinaryChainTest for ConnectionHandshakeTest { trusting_period: None, }); - let (connection_id_a, connection_id_b) = runtime + runtime .block_on(async move { let birelay = builder .bootstrap_birelay(&chain_id_a, &chain_id_b, &client_settings, &client_settings) .await?; - let (src_connection_id, _dst_connection_id) = birelay + let (connection_id_a, connection_id_b) = birelay .relay_a_to_b() .bootstrap_connection(&Default::default()) .await?; + info!( + "bootstrapped new IBC connections with ID {} and {}", + connection_id_a, connection_id_b + ); + let channel_init_options = CosmosInitChannelOptions { ordering: Ordering::Unordered, - connection_hops: vec![src_connection_id], + connection_hops: vec![connection_id_a], channel_version: Version::ics20(), }; - birelay + let (channel_id_a, channel_id_b) = birelay .relay_a_to_b() .bootstrap_channel( &PortId::transfer(), &PortId::transfer(), &channel_init_options, ) - .await + .await?; + + info!( + "bootstrapped new IBC channel with ID {} and {}", + channel_id_a, channel_id_b + ); + + >::Ok(()) }) .unwrap(); - info!( - "bootstrapped new IBC connections with ID {} and {}", - connection_id_a, connection_id_b - ); - Ok(()) } }