diff --git a/ibc-testkit/src/context.rs b/ibc-testkit/src/context.rs index 4380de474d..ea659ad7a1 100644 --- a/ibc-testkit/src/context.rs +++ b/ibc-testkit/src/context.rs @@ -5,8 +5,10 @@ use basecoin_store::context::ProvableStore; use basecoin_store::impls::InMemoryStore; use ibc::core::channel::types::channel::ChannelEnd; use ibc::core::channel::types::commitment::PacketCommitment; -use ibc::core::client::context::client_state::ClientStateValidation; +use ibc::core::client::context::client_state::{ClientStateExecution, ClientStateValidation}; +use ibc::core::client::context::consensus_state::ConsensusState; use ibc::core::client::context::{ClientExecutionContext, ClientValidationContext}; +use ibc::core::client::types::error::ClientError; use ibc::core::client::types::Height; use ibc::core::connection::types::ConnectionEnd; use ibc::core::entrypoint::{dispatch, execute, validate}; @@ -20,11 +22,14 @@ use ibc::core::host::types::path::{ }; use ibc::core::host::{ExecutionContext, ValidationContext}; use ibc::primitives::prelude::*; +use ibc::primitives::proto::Any; use ibc::primitives::Timestamp; use super::testapp::ibc::core::types::{LightClientState, MockIbcStore}; use crate::fixtures::core::context::TestContextConfig; -use crate::hosts::{HostClientState, MockHost, TendermintHost, TestBlock, TestHeader, TestHost}; +use crate::hosts::{ + HostClientState, HostConsensusState, MockHost, TendermintHost, TestBlock, TestHeader, TestHost, +}; use crate::relayer::error::RelayerError; use crate::testapp::ibc::clients::{AnyClientState, AnyConsensusState}; use crate::testapp::ibc::core::router::MockRouter; @@ -32,11 +37,13 @@ use crate::testapp::ibc::core::types::DEFAULT_BLOCK_TIME_SECS; /// A context implementing the dependencies necessary for testing any IBC module. #[derive(Debug)] -pub struct StoreGenericTestContext +pub struct StoreGenericTestContext where S: ProvableStore + Debug, H: TestHost, - HostClientState: ClientStateValidation>, + ACL: From> + ClientStateExecution> + Clone, + ACS: From> + ConsensusState + Clone, + HostClientState: ClientStateValidation>, { /// The multi store of the context. /// This is where the IBC store root is stored at IBC commitment prefix. @@ -46,7 +53,7 @@ where pub host: H, /// An object that stores all IBC related data. - pub ibc_store: MockIbcStore, + pub ibc_store: MockIbcStore, /// A router that can route messages to the appropriate IBC application. pub ibc_router: MockRouter, @@ -54,8 +61,11 @@ where /// A mock store type using basecoin-storage implementations. pub type MockStore = InMemoryStore; -/// A [`StoreGenericTestContext`] using [`MockStore`]. -pub type TestContext = StoreGenericTestContext; +/// A [`StoreGenericTestContext`] using [`MockStore`], [`AnyClientState`], and [`AnyConsensusState`]. +pub type TestContext = StoreGenericTestContext; +/// A [`LightClientState`] using [`MockStore`], [`AnyClientState`] and [`AnyConsensusState`]. +pub type DefaultLightClientState = + LightClientState; /// A [`StoreGenericTestContext`] using [`MockStore`] and [`MockHost`]. pub type MockContext = TestContext; /// A [`StoreGenericTestContext`] using [`MockStore`] and [`TendermintHost`]. @@ -64,11 +74,16 @@ pub type TendermintContext = TestContext; /// Returns a [`StoreGenericTestContext`] with bare minimum initialization: no clients, no connections, and no channels are /// present, and the chain has Height(5). This should be used sparingly, mostly for testing the /// creation of new domain objects. -impl Default for StoreGenericTestContext +impl Default for StoreGenericTestContext where S: ProvableStore + Debug + Default, H: TestHost, - HostClientState: ClientStateValidation>, + ACL: From> + ClientStateExecution> + Clone, + ACS: From> + ConsensusState + Clone, + HostClientState: ClientStateValidation>, + MockIbcStore: + ClientExecutionContext, + ClientError: From<>::Error>, { fn default() -> Self { TestContextConfig::builder().build() @@ -77,19 +92,24 @@ where /// Implementation of internal interface for use in testing. The methods in this interface should /// _not_ be accessible to any ICS handler. -impl StoreGenericTestContext +impl StoreGenericTestContext where S: ProvableStore + Debug, H: TestHost, - HostClientState: ClientStateValidation>, + ACL: From> + ClientStateExecution> + Clone, + ACS: From> + ConsensusState + Clone, + HostClientState: ClientStateValidation>, + MockIbcStore: + ClientExecutionContext, + ClientError: From<>::Error>, { /// Returns an immutable reference to the IBC store. - pub fn ibc_store(&self) -> &MockIbcStore { + pub fn ibc_store(&self) -> &MockIbcStore { &self.ibc_store } /// Returns a mutable reference to the IBC store. - pub fn ibc_store_mut(&mut self) -> &mut MockIbcStore { + pub fn ibc_store_mut(&mut self) -> &mut MockIbcStore { &mut self.ibc_store } @@ -170,12 +190,12 @@ where /// and consensus, and prepares the context for the next block. This includes /// the latest consensus state and the latest IBC commitment proof. pub fn begin_block(&mut self) { - let consensus_state = self - .host - .latest_block() - .into_header() - .into_consensus_state() - .into(); + let consensus_state = ACS::from( + self.host + .latest_block() + .into_header() + .into_consensus_state(), + ); let ibc_commitment_proof = self .multi_store @@ -274,7 +294,7 @@ where } /// Bootstraps the context with a client state and its corresponding [`ClientId`]. - pub fn with_client_state(mut self, client_id: &ClientId, client_state: AnyClientState) -> Self { + pub fn with_client_state(mut self, client_id: &ClientId, client_state: ACL) -> Self { let client_state_path = ClientStatePath::new(client_id.clone()); self.ibc_store .store_client_state(client_state_path, client_state) @@ -287,7 +307,7 @@ where mut self, client_id: &ClientId, height: Height, - consensus_state: AnyConsensusState, + consensus_state: ACS, ) -> Self { let consensus_state_path = ClientConsensusStatePath::new( client_id.clone(), @@ -308,7 +328,7 @@ where &self, mut consensus_heights: Vec, client_params: &H::LightClientParams, - ) -> LightClientState { + ) -> LightClientState { let client_height = if let Some(&height) = consensus_heights.last() { height } else { @@ -336,6 +356,7 @@ where LightClientState { client_state, consensus_states, + _phantom: core::marker::PhantomData, } } @@ -343,15 +364,17 @@ where pub fn with_light_client( mut self, client_id: &ClientId, - light_client: LightClientState, + light_client: LightClientState, ) -> Self where RH: TestHost, + ACL: From>, + ACS: From>, { - self = self.with_client_state(client_id, light_client.client_state.into()); + self = self.with_client_state(client_id, ACL::from(light_client.client_state)); for (height, consensus_state) in light_client.consensus_states { - self = self.with_consensus_state(client_id, height, consensus_state.into()); + self = self.with_consensus_state(client_id, height, ACS::from(consensus_state)); self.ibc_store .store_update_meta( @@ -512,6 +535,8 @@ mod tests { pub struct Test where H: TestHost, + AnyClientState: From>, + AnyConsensusState: From>, HostConsensusState: ConsensusState, HostClientState: ClientStateValidation, { @@ -522,6 +547,8 @@ mod tests { fn run_tests(sub_title: &str) where H: TestHost, + AnyClientState: From>, + AnyConsensusState: From>, HostConsensusState: ConsensusState, HostClientState: ClientStateValidation, { diff --git a/ibc-testkit/src/fixtures/core/context.rs b/ibc-testkit/src/fixtures/core/context.rs index 99304f0e06..22e685c4ff 100644 --- a/ibc-testkit/src/fixtures/core/context.rs +++ b/ibc-testkit/src/fixtures/core/context.rs @@ -2,14 +2,18 @@ use alloc::fmt::Debug; use core::time::Duration; use basecoin_store::context::ProvableStore; -use ibc::core::client::context::client_state::ClientStateValidation; +use ibc::core::client::context::client_state::{ClientStateExecution, ClientStateValidation}; +use ibc::core::client::context::consensus_state::ConsensusState; +use ibc::core::client::context::ClientExecutionContext; +use ibc::core::client::types::error::ClientError; use ibc::core::client::types::Height; use ibc::core::primitives::prelude::*; use ibc::core::primitives::Timestamp; +use ibc::primitives::proto::Any; use typed_builder::TypedBuilder; use crate::context::StoreGenericTestContext; -use crate::hosts::{HostClientState, TestBlock, TestHost}; +use crate::hosts::{HostClientState, HostConsensusState, TestBlock, TestHost}; use crate::testapp::ibc::core::router::MockRouter; use crate::testapp::ibc::core::types::{MockIbcStore, DEFAULT_BLOCK_TIME_SECS}; use crate::utils::year_2023; @@ -37,11 +41,17 @@ where latest_height: Height, } -impl From> for StoreGenericTestContext +impl From> for StoreGenericTestContext where S: ProvableStore + Debug + Default, H: TestHost, - HostClientState: ClientStateValidation>, + S: ProvableStore + Debug, + ACL: From> + ClientStateExecution> + Clone, + ACS: From> + ConsensusState + Clone, + HostClientState: ClientStateValidation>, + MockIbcStore: + ClientExecutionContext, + ClientError: From<>::Error>, { fn from(params: TestContextConfig) -> Self { assert_ne!( diff --git a/ibc-testkit/src/hosts/mod.rs b/ibc-testkit/src/hosts/mod.rs index 86b17cc54f..33d39cd63f 100644 --- a/ibc-testkit/src/hosts/mod.rs +++ b/ibc-testkit/src/hosts/mod.rs @@ -13,7 +13,6 @@ use ibc::primitives::proto::Any; pub use self::mock::MockHost; pub use self::tendermint::TendermintHost; -use crate::testapp::ibc::clients::{AnyClientState, AnyConsensusState}; pub type HostClientState = ::ClientState; pub type HostBlock = ::Block; @@ -28,7 +27,7 @@ pub trait TestHost: Default + Debug + Sized { type Block: TestBlock; /// The type of client state produced by the host. - type ClientState: Into + Debug; + type ClientState: Debug; /// The type of block parameter to produce a block. type BlockParams: Debug + Default; @@ -142,7 +141,7 @@ pub trait TestBlock: Clone + Debug { /// submitted by relayer from the host blockchain. pub trait TestHeader: Clone + Debug + Into { /// The type of consensus state can be extracted from the header. - type ConsensusState: ConsensusState + Into + From + Clone + Debug; + type ConsensusState: ConsensusState + From + Clone + Debug; /// The height of the block, as recorded in the header. fn height(&self) -> Height; diff --git a/ibc-testkit/src/relayer/context.rs b/ibc-testkit/src/relayer/context.rs index 9ea3bd1962..36edffcd75 100644 --- a/ibc-testkit/src/relayer/context.rs +++ b/ibc-testkit/src/relayer/context.rs @@ -1,74 +1,110 @@ +use core::fmt::Debug; + +use basecoin_store::context::ProvableStore; use ibc::core::channel::types::packet::Packet; -use ibc::core::client::context::client_state::ClientStateValidation; +use ibc::core::client::context::client_state::ClientStateExecution; +use ibc::core::client::context::consensus_state::ConsensusState; +use ibc::core::client::context::ClientExecutionContext; +use ibc::core::client::types::error::ClientError; use ibc::core::host::types::identifiers::{ChannelId, ClientId, ConnectionId, PortId}; use ibc::core::host::types::path::ChannelEndPath; use ibc::core::host::ValidationContext; +use ibc::primitives::proto::Any; use ibc::primitives::Signer; -use crate::context::TestContext; -use crate::hosts::{HostClientState, TestHost}; +use crate::context::StoreGenericTestContext; +use crate::hosts::{HostClientState, HostConsensusState, TestHost}; use crate::relayer::utils::TypedRelayerOps; -use crate::testapp::ibc::core::types::DefaultIbcStore; +use crate::testapp::ibc::core::types::MockIbcStore; -/// A relayer context that allows interaction between two [`TestContext`] instances. -pub struct RelayerContext +/// A relayer context that allows interaction between two [`StoreGenericTestContext`] instances. +pub struct RelayerContext where A: TestHost, B: TestHost, - HostClientState: ClientStateValidation, - HostClientState: ClientStateValidation, + S: ProvableStore + Debug, + ACL: From> + + From> + + ClientStateExecution> + + Clone, + ACS: From> + From> + ConsensusState + Clone, + HostClientState: ClientStateExecution>, + HostClientState: ClientStateExecution>, + MockIbcStore: + ClientExecutionContext, + ClientError: From<>::Error>, { - ctx_a: TestContext, - ctx_b: TestContext, + ctx_a: StoreGenericTestContext, + ctx_b: StoreGenericTestContext, } -impl RelayerContext +impl RelayerContext where A: TestHost, B: TestHost, - HostClientState: ClientStateValidation, - HostClientState: ClientStateValidation, + S: ProvableStore + Debug, + ACL: From> + + From> + + ClientStateExecution> + + Clone, + ACS: From> + From> + ConsensusState + Clone, + HostClientState: ClientStateExecution>, + HostClientState: ClientStateExecution>, + MockIbcStore: + ClientExecutionContext, + ClientError: From<>::Error>, { - /// Creates a new relayer context with the given [`TestContext`] instances. - pub fn new(ctx_a: TestContext, ctx_b: TestContext) -> Self { + /// Creates a new relayer context with the given [`StoreGenericTestContext`] instances. + pub fn new( + ctx_a: StoreGenericTestContext, + ctx_b: StoreGenericTestContext, + ) -> Self { Self { ctx_a, ctx_b } } /// Returns an immutable reference to the first context. - pub fn get_ctx_a(&self) -> &TestContext { + pub fn get_ctx_a(&self) -> &StoreGenericTestContext { &self.ctx_a } /// Returns an immutable reference to the second context. - pub fn get_ctx_b(&self) -> &TestContext { + pub fn get_ctx_b(&self) -> &StoreGenericTestContext { &self.ctx_b } /// Returns a mutable reference to the first context. - pub fn get_ctx_a_mut(&mut self) -> &mut TestContext { + pub fn get_ctx_a_mut(&mut self) -> &mut StoreGenericTestContext { &mut self.ctx_a } /// Returns a mutable reference to the second context. - pub fn get_ctx_b_mut(&mut self) -> &mut TestContext { + pub fn get_ctx_b_mut(&mut self) -> &mut StoreGenericTestContext { &mut self.ctx_b } /// Creates a light client of second context on the first context. /// Returns the client identifier of the created client. pub fn create_client_on_a(&mut self, signer: Signer) -> ClientId { - TypedRelayerOps::::create_client_on_a(&mut self.ctx_a, &self.ctx_b, signer) + TypedRelayerOps::::create_client_on_a( + &mut self.ctx_a, + &self.ctx_b, + signer, + ) } /// Creates a light client of first context on the second context. /// Returns the client identifier of the created client. pub fn create_client_on_b(&mut self, signer: Signer) -> ClientId { - TypedRelayerOps::::create_client_on_a(&mut self.ctx_b, &self.ctx_a, signer) + TypedRelayerOps::::create_client_on_a( + &mut self.ctx_b, + &self.ctx_a, + signer, + ) } /// Updates the client on the first context with the latest header of the second context. pub fn update_client_on_a_with_sync(&mut self, client_id_on_a: ClientId, signer: Signer) { - TypedRelayerOps::::update_client_on_a_with_sync( + TypedRelayerOps::::update_client_on_a_with_sync( &mut self.ctx_a, &mut self.ctx_b, client_id_on_a, @@ -78,7 +114,7 @@ where /// Updates the client on the second context with the latest header of the first context. pub fn update_client_on_b_with_sync(&mut self, client_id_on_b: ClientId, signer: Signer) { - TypedRelayerOps::::update_client_on_a_with_sync( + TypedRelayerOps::::update_client_on_a_with_sync( &mut self.ctx_b, &mut self.ctx_a, client_id_on_b, @@ -94,7 +130,7 @@ where client_id_on_b: ClientId, signer: Signer, ) -> (ConnectionId, ConnectionId) { - TypedRelayerOps::::create_connection_on_a( + TypedRelayerOps::::create_connection_on_a( &mut self.ctx_a, &mut self.ctx_b, client_id_on_a, @@ -111,7 +147,7 @@ where client_id_on_a: ClientId, signer: Signer, ) -> (ConnectionId, ConnectionId) { - TypedRelayerOps::::create_connection_on_a( + TypedRelayerOps::::create_connection_on_a( &mut self.ctx_b, &mut self.ctx_a, client_id_on_b, @@ -146,7 +182,7 @@ where .client_id() .clone(); - TypedRelayerOps::::create_channel_on_a( + TypedRelayerOps::::create_channel_on_a( &mut self.ctx_a, &mut self.ctx_b, client_id_on_a, @@ -185,7 +221,7 @@ where .client_id() .clone(); - TypedRelayerOps::::create_channel_on_a( + TypedRelayerOps::::create_channel_on_a( &mut self.ctx_b, &mut self.ctx_a, client_id_on_b, @@ -239,7 +275,7 @@ where .client_id() .clone(); - TypedRelayerOps::::close_channel_on_a( + TypedRelayerOps::::close_channel_on_a( &mut self.ctx_a, &mut self.ctx_b, client_id_on_a, @@ -293,7 +329,7 @@ where .client_id() .clone(); - TypedRelayerOps::::close_channel_on_a( + TypedRelayerOps::::close_channel_on_a( &mut self.ctx_b, &mut self.ctx_a, client_id_on_b, @@ -349,7 +385,7 @@ where .client_id() .clone(); - TypedRelayerOps::::submit_packet_on_b( + TypedRelayerOps::::submit_packet_on_b( &mut self.ctx_a, &mut self.ctx_b, packet, @@ -402,7 +438,7 @@ where .client_id() .clone(); - TypedRelayerOps::::timeout_packet_from_a( + TypedRelayerOps::::timeout_packet_from_a( &mut self.ctx_a, &mut self.ctx_b, packet, @@ -455,7 +491,7 @@ where .client_id() .clone(); - TypedRelayerOps::::timeout_packet_from_a_on_channel_close( + TypedRelayerOps::::timeout_packet_from_a_on_channel_close( &mut self.ctx_a, &mut self.ctx_b, packet, diff --git a/ibc-testkit/src/relayer/integration.rs b/ibc-testkit/src/relayer/integration.rs index 145ed50044..536cf65820 100644 --- a/ibc-testkit/src/relayer/integration.rs +++ b/ibc-testkit/src/relayer/integration.rs @@ -1,11 +1,18 @@ -use ibc::core::client::context::client_state::ClientStateValidation; +use core::fmt::Debug; + +use basecoin_store::context::ProvableStore; +use ibc::core::client::context::client_state::ClientStateExecution; +use ibc::core::client::context::consensus_state::ConsensusState; +use ibc::core::client::context::ClientExecutionContext; +use ibc::core::client::types::error::ClientError; use ibc::core::host::types::identifiers::{ChannelId, ConnectionId, PortId}; +use ibc::primitives::proto::Any; -use crate::context::TestContext; +use crate::context::StoreGenericTestContext; use crate::fixtures::core::signer::dummy_account_id; -use crate::hosts::{HostClientState, TestHost}; +use crate::hosts::{HostClientState, HostConsensusState, TestHost}; use crate::relayer::context::RelayerContext; -use crate::testapp::ibc::core::types::DefaultIbcStore; +use crate::testapp::ibc::core::types::MockIbcStore; /// Integration test for IBC implementation. This test creates clients, /// connections, channels between two [`TestHost`]s. @@ -13,15 +20,24 @@ use crate::testapp::ibc::core::types::DefaultIbcStore; /// If `serde` feature is enabled, this also exercises packet relay between [`TestHost`]s. This uses /// [`DummyTransferModule`](crate::testapp::ibc::applications::transfer::types::DummyTransferModule) /// to simulate the transfer of tokens between two contexts. -pub fn ibc_integration_test() +pub fn ibc_integration_test() where A: TestHost, B: TestHost, - HostClientState: ClientStateValidation, - HostClientState: ClientStateValidation, + S: ProvableStore + Debug + Default, + ACL: From> + + From> + + ClientStateExecution> + + Clone, + ACS: From> + From> + ConsensusState + Clone, + HostClientState: ClientStateExecution>, + HostClientState: ClientStateExecution>, + MockIbcStore: + ClientExecutionContext, + ClientError: From<>::Error>, { - let ctx_a = TestContext::::default(); - let ctx_b = TestContext::::default(); + let ctx_a = StoreGenericTestContext::::default(); + let ctx_b = StoreGenericTestContext::::default(); let signer = dummy_account_id(); @@ -165,14 +181,29 @@ where #[cfg(test)] mod tests { use super::*; + use crate::context::MockStore; use crate::hosts::{MockHost, TendermintHost}; + use crate::testapp::ibc::clients::{AnyClientState, AnyConsensusState}; + use crate::testapp::ibc::core::types::DefaultIbcStore; // tests among all the `TestHost` implementations #[test] fn ibc_integration_test_for_all_pairs() { - ibc_integration_test::(); - ibc_integration_test::(); - ibc_integration_test::(); - ibc_integration_test::(); + fn default_ibc_integration_test() + where + A: TestHost, + B: TestHost, + AnyClientState: From> + From>, + AnyConsensusState: From> + From>, + HostClientState: ClientStateExecution, + HostClientState: ClientStateExecution, + { + ibc_integration_test::(); + } + + default_ibc_integration_test::(); + default_ibc_integration_test::(); + default_ibc_integration_test::(); + default_ibc_integration_test::(); } } diff --git a/ibc-testkit/src/relayer/utils.rs b/ibc-testkit/src/relayer/utils.rs index cd3c5f0a35..c9562fe2b6 100644 --- a/ibc-testkit/src/relayer/utils.rs +++ b/ibc-testkit/src/relayer/utils.rs @@ -1,7 +1,9 @@ use alloc::string::String; +use core::fmt::Debug; use core::marker::PhantomData; use core::time::Duration; +use basecoin_store::context::ProvableStore; use ibc::core::channel::types::acknowledgement::Acknowledgement; use ibc::core::channel::types::channel::Order; use ibc::core::channel::types::msgs::{ @@ -12,8 +14,10 @@ use ibc::core::channel::types::msgs::{ use ibc::core::channel::types::packet::Packet; use ibc::core::channel::types::timeout::TimeoutHeight; use ibc::core::channel::types::Version as ChannelVersion; -use ibc::core::client::context::client_state::ClientStateValidation; -use ibc::core::client::context::ClientValidationContext; +use ibc::core::client::context::client_state::ClientStateExecution; +use ibc::core::client::context::consensus_state::ConsensusState; +use ibc::core::client::context::{ClientExecutionContext, ClientValidationContext}; +use ibc::core::client::types::error::ClientError; use ibc::core::client::types::msgs::{ClientMsg, MsgCreateClient, MsgUpdateClient}; use ibc::core::connection::types::msgs::{ ConnectionMsg, MsgConnectionOpenAck, MsgConnectionOpenConfirm, MsgConnectionOpenInit, @@ -29,12 +33,13 @@ use ibc::core::host::types::path::{ ConnectionPath, ReceiptPath, }; use ibc::core::host::ValidationContext; +use ibc::primitives::proto::Any; use ibc::primitives::Signer; use ibc_query::core::context::ProvableContext; -use crate::context::TestContext; -use crate::hosts::{HostClientState, TestBlock, TestHost}; -use crate::testapp::ibc::core::types::{DefaultIbcStore, LightClientBuilder, LightClientState}; +use crate::context::StoreGenericTestContext; +use crate::hosts::{HostClientState, HostConsensusState, TestBlock, TestHost}; +use crate::testapp::ibc::core::types::{LightClientBuilder, LightClientState, MockIbcStore}; /// Implements IBC relayer functions for a pair of [`TestHost`] implementations: `A` and `B`. /// Note that, all the implementations are in one direction: from `A` to `B`. @@ -43,30 +48,48 @@ use crate::testapp::ibc::core::types::{DefaultIbcStore, LightClientBuilder, Ligh /// /// For the functions in the opposite direction, use `TypedRelayerOps::` instead of TypedRelayerOps::`. #[derive(Debug, Default)] -pub struct TypedRelayerOps(PhantomData, PhantomData) +pub struct TypedRelayerOps(PhantomData<(A, B, S, ACL, ACS)>) where A: TestHost, B: TestHost, - HostClientState: ClientStateValidation, - HostClientState: ClientStateValidation; - -impl TypedRelayerOps + S: ProvableStore + Debug, + ACL: From> + + From> + + ClientStateExecution> + + Clone, + ACS: From> + From> + ConsensusState + Clone, + HostClientState: ClientStateExecution>, + HostClientState: ClientStateExecution>, + MockIbcStore: + ClientExecutionContext, + ClientError: From<>::Error>; + +impl TypedRelayerOps where A: TestHost, B: TestHost, - HostClientState: ClientStateValidation, - HostClientState: ClientStateValidation, + S: ProvableStore + Debug, + ACL: From> + + From> + + ClientStateExecution> + + Clone, + ACS: From> + From> + ConsensusState + Clone, + HostClientState: ClientStateExecution>, + HostClientState: ClientStateExecution>, + MockIbcStore: + ClientExecutionContext, + ClientError: From<>::Error>, { /// Creates a client on `A` with the state of `B`. /// Returns the client identifier on `A`. pub fn create_client_on_a( - ctx_a: &mut TestContext, - ctx_b: &TestContext, + ctx_a: &mut StoreGenericTestContext, + ctx_b: &StoreGenericTestContext, signer: Signer, ) -> ClientId { let light_client_of_b = LightClientBuilder::init() .context(ctx_b) - .build::>(); + .build::>(); let msg_for_a = MsgEnvelope::Client(ClientMsg::CreateClient(MsgCreateClient { client_state: light_client_of_b.client_state.into(), @@ -102,7 +125,10 @@ where } /// Advances the block height on `A` until it catches up with the latest timestamp on `B`. - pub fn sync_clock_on_a(ctx_a: &mut TestContext, ctx_b: &TestContext) { + pub fn sync_clock_on_a( + ctx_a: &mut StoreGenericTestContext, + ctx_b: &StoreGenericTestContext, + ) { while ctx_b.latest_timestamp() > ctx_a.latest_timestamp() { ctx_a.advance_block_height(); } @@ -110,8 +136,8 @@ where /// Updates the client on `A` with the latest header from `B`. pub fn update_client_on_a( - ctx_a: &mut TestContext, - ctx_b: &TestContext, + ctx_a: &mut StoreGenericTestContext, + ctx_b: &StoreGenericTestContext, client_id_on_a: ClientId, signer: Signer, ) { @@ -151,20 +177,25 @@ where /// /// Timestamp sync is required, as IBC doesn't allow client updates from the future beyond max clock drift. pub fn update_client_on_a_with_sync( - ctx_a: &mut TestContext, - ctx_b: &mut TestContext, + ctx_a: &mut StoreGenericTestContext, + ctx_b: &mut StoreGenericTestContext, client_id_on_a: ClientId, signer: Signer, ) { - TypedRelayerOps::::sync_clock_on_a(ctx_a, ctx_b); - TypedRelayerOps::::update_client_on_a(ctx_a, ctx_b, client_id_on_a, signer); + TypedRelayerOps::::sync_clock_on_a(ctx_a, ctx_b); + TypedRelayerOps::::update_client_on_a( + ctx_a, + ctx_b, + client_id_on_a, + signer, + ); } /// `A` initiates a connection with the other end on `B`. /// Returns the connection identifier on `A`. pub fn connection_open_init_on_a( - ctx_a: &mut TestContext, - ctx_b: &TestContext, + ctx_a: &mut StoreGenericTestContext, + ctx_b: &StoreGenericTestContext, client_id_on_a: ClientId, client_id_on_b: ClientId, signer: Signer, @@ -197,8 +228,8 @@ where /// `B` receives the connection opening attempt by `A` after `A` initiates the connection. /// Returns the connection identifier on `B`. pub fn connection_open_try_on_b( - ctx_b: &mut TestContext, - ctx_a: &TestContext, + ctx_b: &mut StoreGenericTestContext, + ctx_a: &StoreGenericTestContext, conn_id_on_a: ConnectionId, client_id_on_a: ClientId, client_id_on_b: ClientId, @@ -286,8 +317,8 @@ where /// `A` receives `B`'s acknowledgement that `B` received the connection opening attempt by `A`. /// `A` starts processing the connection on its side. pub fn connection_open_ack_on_a( - ctx_a: &mut TestContext, - ctx_b: &TestContext, + ctx_a: &mut StoreGenericTestContext, + ctx_b: &StoreGenericTestContext, conn_id_on_a: ConnectionId, conn_id_on_b: ConnectionId, client_id_on_b: ClientId, @@ -362,8 +393,8 @@ where /// `B` receives the confirmation from `A` that the connection creation was successful. /// `B` also starts processing the connection on its side. pub fn connection_open_confirm_on_b( - ctx_b: &mut TestContext, - ctx_a: &TestContext, + ctx_b: &mut StoreGenericTestContext, + ctx_a: &StoreGenericTestContext, conn_id_on_a: ConnectionId, conn_id_on_b: ConnectionId, signer: Signer, @@ -399,13 +430,13 @@ where /// A connection is created by `A` towards `B` using the IBC connection handshake protocol. /// Returns the connection identifiers of `A` and `B`. pub fn create_connection_on_a( - ctx_a: &mut TestContext, - ctx_b: &mut TestContext, + ctx_a: &mut StoreGenericTestContext, + ctx_b: &mut StoreGenericTestContext, client_id_on_a: ClientId, client_id_on_b: ClientId, signer: Signer, ) -> (ConnectionId, ConnectionId) { - let conn_id_on_a = TypedRelayerOps::::connection_open_init_on_a( + let conn_id_on_a = TypedRelayerOps::::connection_open_init_on_a( ctx_a, ctx_b, client_id_on_a.clone(), @@ -413,14 +444,14 @@ where signer.clone(), ); - TypedRelayerOps::::update_client_on_a_with_sync( + TypedRelayerOps::::update_client_on_a_with_sync( ctx_b, ctx_a, client_id_on_b.clone(), signer.clone(), ); - let conn_id_on_b = TypedRelayerOps::::connection_open_try_on_b( + let conn_id_on_b = TypedRelayerOps::::connection_open_try_on_b( ctx_b, ctx_a, conn_id_on_a.clone(), @@ -429,14 +460,14 @@ where signer.clone(), ); - TypedRelayerOps::::update_client_on_a_with_sync( + TypedRelayerOps::::update_client_on_a_with_sync( ctx_a, ctx_b, client_id_on_a.clone(), signer.clone(), ); - TypedRelayerOps::::connection_open_ack_on_a( + TypedRelayerOps::::connection_open_ack_on_a( ctx_a, ctx_b, conn_id_on_a.clone(), @@ -445,14 +476,14 @@ where signer.clone(), ); - TypedRelayerOps::::update_client_on_a_with_sync( + TypedRelayerOps::::update_client_on_a_with_sync( ctx_b, ctx_a, client_id_on_b.clone(), signer.clone(), ); - TypedRelayerOps::::connection_open_confirm_on_b( + TypedRelayerOps::::connection_open_confirm_on_b( ctx_b, ctx_a, conn_id_on_b.clone(), @@ -460,7 +491,12 @@ where signer.clone(), ); - TypedRelayerOps::::update_client_on_a_with_sync(ctx_a, ctx_b, client_id_on_a, signer); + TypedRelayerOps::::update_client_on_a_with_sync( + ctx_a, + ctx_b, + client_id_on_a, + signer, + ); (conn_id_on_a, conn_id_on_b) } @@ -468,7 +504,7 @@ where /// `A` initiates a channel with port identifier with the other end on `B`. /// Returns the channel identifier of `A`. pub fn channel_open_init_on_a( - ctx_a: &mut TestContext, + ctx_a: &mut StoreGenericTestContext, conn_id_on_a: ConnectionId, port_id_on_a: PortId, port_id_on_b: PortId, @@ -497,8 +533,8 @@ where /// `B` receives the channel opening attempt by `A` after `A` initiates the channel. /// Returns the channel identifier of `B`. pub fn channel_open_try_on_b( - ctx_b: &mut TestContext, - ctx_a: &TestContext, + ctx_b: &mut StoreGenericTestContext, + ctx_a: &StoreGenericTestContext, conn_id_on_b: ConnectionId, chan_id_on_a: ChannelId, port_id_on_a: PortId, @@ -545,8 +581,8 @@ where /// `A` receives `B`'s acknowledgement that `B` received the channel opening attempt by `A`. /// `A` starts processing the channel on its side. pub fn channel_open_ack_on_a( - ctx_a: &mut TestContext, - ctx_b: &TestContext, + ctx_a: &mut StoreGenericTestContext, + ctx_b: &StoreGenericTestContext, chan_id_on_a: ChannelId, port_id_on_a: PortId, chan_id_on_b: ChannelId, @@ -586,8 +622,8 @@ where /// `B` receives the confirmation from `A` that the channel creation was successful. /// `B` also starts processing the channel on its side. pub fn channel_open_confirm_on_b( - ctx_b: &mut TestContext, - ctx_a: &TestContext, + ctx_b: &mut StoreGenericTestContext, + ctx_a: &StoreGenericTestContext, chan_id_on_a: ChannelId, chan_id_on_b: ChannelId, port_id_on_b: PortId, @@ -624,7 +660,7 @@ where /// `A` initiates the channel closing, with the other end on `B`. /// `A` stops processing the channel. pub fn channel_close_init_on_a( - ctx_a: &mut TestContext, + ctx_a: &mut StoreGenericTestContext, chan_id_on_a: ChannelId, port_id_on_a: PortId, signer: Signer, @@ -646,8 +682,8 @@ where /// `B` receives the channel closing attempt by `A` after `A` initiates the channel closing. /// `B` also stops processing the channel. pub fn channel_close_confirm_on_b( - ctx_b: &mut TestContext, - ctx_a: &TestContext, + ctx_b: &mut StoreGenericTestContext, + ctx_a: &StoreGenericTestContext, chan_id_on_b: ChannelId, port_id_on_b: PortId, signer: Signer, @@ -685,8 +721,8 @@ where /// Returns the channel identifiers of `A` and `B`. #[allow(clippy::too_many_arguments)] pub fn create_channel_on_a( - ctx_a: &mut TestContext, - ctx_b: &mut TestContext, + ctx_a: &mut StoreGenericTestContext, + ctx_b: &mut StoreGenericTestContext, client_id_on_a: ClientId, conn_id_on_a: ConnectionId, port_id_on_a: PortId, @@ -695,7 +731,7 @@ where port_id_on_b: PortId, signer: Signer, ) -> (ChannelId, ChannelId) { - let chan_id_on_a = TypedRelayerOps::::channel_open_init_on_a( + let chan_id_on_a = TypedRelayerOps::::channel_open_init_on_a( ctx_a, conn_id_on_a.clone(), port_id_on_a.clone(), @@ -703,14 +739,14 @@ where signer.clone(), ); - TypedRelayerOps::::update_client_on_a_with_sync( + TypedRelayerOps::::update_client_on_a_with_sync( ctx_b, ctx_a, client_id_on_b.clone(), signer.clone(), ); - let chan_id_on_b = TypedRelayerOps::::channel_open_try_on_b( + let chan_id_on_b = TypedRelayerOps::::channel_open_try_on_b( ctx_b, ctx_a, conn_id_on_b.clone(), @@ -719,14 +755,14 @@ where signer.clone(), ); - TypedRelayerOps::::update_client_on_a_with_sync( + TypedRelayerOps::::update_client_on_a_with_sync( ctx_a, ctx_b, client_id_on_a.clone(), signer.clone(), ); - TypedRelayerOps::::channel_open_ack_on_a( + TypedRelayerOps::::channel_open_ack_on_a( ctx_a, ctx_b, chan_id_on_a.clone(), @@ -736,14 +772,14 @@ where signer.clone(), ); - TypedRelayerOps::::update_client_on_a_with_sync( + TypedRelayerOps::::update_client_on_a_with_sync( ctx_b, ctx_a, client_id_on_b.clone(), signer.clone(), ); - TypedRelayerOps::::channel_open_confirm_on_b( + TypedRelayerOps::::channel_open_confirm_on_b( ctx_b, ctx_a, chan_id_on_a.clone(), @@ -752,7 +788,12 @@ where signer.clone(), ); - TypedRelayerOps::::update_client_on_a_with_sync(ctx_a, ctx_b, client_id_on_a, signer); + TypedRelayerOps::::update_client_on_a_with_sync( + ctx_a, + ctx_b, + client_id_on_a, + signer, + ); (chan_id_on_a, chan_id_on_b) } @@ -760,8 +801,8 @@ where /// A channel is closed by `A` towards `B` using the IBC channel handshake protocol. #[allow(clippy::too_many_arguments)] pub fn close_channel_on_a( - ctx_a: &mut TestContext, - ctx_b: &mut TestContext, + ctx_a: &mut StoreGenericTestContext, + ctx_b: &mut StoreGenericTestContext, client_id_on_a: ClientId, chan_id_on_a: ChannelId, port_id_on_a: PortId, @@ -770,21 +811,21 @@ where port_id_on_b: PortId, signer: Signer, ) { - TypedRelayerOps::::channel_close_init_on_a( + TypedRelayerOps::::channel_close_init_on_a( ctx_a, chan_id_on_a.clone(), port_id_on_a.clone(), signer.clone(), ); - TypedRelayerOps::::update_client_on_a_with_sync( + TypedRelayerOps::::update_client_on_a_with_sync( ctx_b, ctx_a, client_id_on_b, signer.clone(), ); - TypedRelayerOps::::channel_close_confirm_on_b( + TypedRelayerOps::::channel_close_confirm_on_b( ctx_b, ctx_a, chan_id_on_b, @@ -792,14 +833,19 @@ where signer.clone(), ); - TypedRelayerOps::::update_client_on_a_with_sync(ctx_a, ctx_b, client_id_on_a, signer); + TypedRelayerOps::::update_client_on_a_with_sync( + ctx_a, + ctx_b, + client_id_on_a, + signer, + ); } /// `B` receives a packet from an IBC module on `A`. /// Returns `B`'s acknowledgement of receipt. pub fn packet_recv_on_b( - ctx_b: &mut TestContext, - ctx_a: &TestContext, + ctx_b: &mut StoreGenericTestContext, + ctx_a: &StoreGenericTestContext, packet: Packet, signer: Signer, ) -> Acknowledgement { @@ -836,8 +882,8 @@ where /// `A` receives the acknowledgement from `B` that `B` received the packet from `A`. pub fn packet_ack_on_a( - ctx_a: &mut TestContext, - ctx_b: &TestContext, + ctx_a: &mut StoreGenericTestContext, + ctx_b: &StoreGenericTestContext, packet: Packet, acknowledgement: Acknowledgement, signer: Signer, @@ -873,8 +919,8 @@ where /// `A` receives the timeout packet from `B`. /// That is, `B` has not received the packet from `A` within the timeout period. pub fn packet_timeout_on_a( - ctx_a: &mut TestContext, - ctx_b: &TestContext, + ctx_a: &mut StoreGenericTestContext, + ctx_b: &StoreGenericTestContext, packet: Packet, signer: Signer, ) { @@ -910,8 +956,8 @@ where /// `A` receives the timeout packet from `B` after closing the channel. /// That is, `B` has not received the packet from `A` because the channel is closed. pub fn packet_timeout_on_close_on_a( - ctx_a: &mut TestContext, - ctx_b: &TestContext, + ctx_a: &mut StoreGenericTestContext, + ctx_b: &StoreGenericTestContext, packet: Packet, chan_id_on_b: ChannelId, port_id_on_b: PortId, @@ -958,8 +1004,8 @@ where /// Sends a packet from an IBC application on `A` to `B` using the IBC packet relay protocol. pub fn submit_packet_on_b( - ctx_a: &mut TestContext, - ctx_b: &mut TestContext, + ctx_a: &mut StoreGenericTestContext, + ctx_b: &mut StoreGenericTestContext, packet: Packet, client_id_on_a: ClientId, client_id_on_b: ClientId, @@ -967,24 +1013,28 @@ where ) { // packet is passed from module - TypedRelayerOps::::update_client_on_a_with_sync( + TypedRelayerOps::::update_client_on_a_with_sync( ctx_b, ctx_a, client_id_on_b.clone(), signer.clone(), ); - let acknowledgement = - TypedRelayerOps::::packet_recv_on_b(ctx_b, ctx_a, packet.clone(), signer.clone()); + let acknowledgement = TypedRelayerOps::::packet_recv_on_b( + ctx_b, + ctx_a, + packet.clone(), + signer.clone(), + ); - TypedRelayerOps::::update_client_on_a_with_sync( + TypedRelayerOps::::update_client_on_a_with_sync( ctx_a, ctx_b, client_id_on_a, signer.clone(), ); - TypedRelayerOps::::packet_ack_on_a( + TypedRelayerOps::::packet_ack_on_a( ctx_a, ctx_b, packet, @@ -992,7 +1042,7 @@ where signer.clone(), ); - TypedRelayerOps::::update_client_on_a_with_sync( + TypedRelayerOps::::update_client_on_a_with_sync( ctx_b, ctx_a, client_id_on_b, @@ -1002,8 +1052,8 @@ where /// Times out a packet from an IBC application on `A` to `B` after waiting timeout period. pub fn timeout_packet_from_a( - ctx_a: &mut TestContext, - ctx_b: &mut TestContext, + ctx_a: &mut StoreGenericTestContext, + ctx_b: &mut StoreGenericTestContext, packet: Packet, client_id_on_a: ClientId, client_id_on_b: ClientId, @@ -1022,7 +1072,7 @@ where } // update client on `A` with the latest header from `B`. - TypedRelayerOps::::update_client_on_a_with_sync( + TypedRelayerOps::::update_client_on_a_with_sync( ctx_a, ctx_b, client_id_on_a.clone(), @@ -1030,10 +1080,15 @@ where ); // timeout the packet on `A`. - TypedRelayerOps::::packet_timeout_on_a(ctx_a, ctx_b, packet.clone(), signer.clone()); + TypedRelayerOps::::packet_timeout_on_a( + ctx_a, + ctx_b, + packet.clone(), + signer.clone(), + ); // `A` has progressed; update client on `B` with the latest header from `A`. - TypedRelayerOps::::update_client_on_a_with_sync( + TypedRelayerOps::::update_client_on_a_with_sync( ctx_b, ctx_a, client_id_on_b, @@ -1043,8 +1098,8 @@ where /// Times out a packet from an IBC application on `A` to `B` after closing the channel. pub fn timeout_packet_from_a_on_channel_close( - ctx_a: &mut TestContext, - ctx_b: &mut TestContext, + ctx_a: &mut StoreGenericTestContext, + ctx_b: &mut StoreGenericTestContext, packet: Packet, client_id_on_a: ClientId, client_id_on_b: ClientId, @@ -1053,7 +1108,7 @@ where // packet is passed from module // close the channel on `A`. - TypedRelayerOps::::close_channel_on_a( + TypedRelayerOps::::close_channel_on_a( ctx_a, ctx_b, client_id_on_a.clone(), @@ -1066,7 +1121,7 @@ where ); // timeout the packet on `A`. - TypedRelayerOps::::packet_timeout_on_close_on_a( + TypedRelayerOps::::packet_timeout_on_close_on_a( ctx_a, ctx_b, packet.clone(), @@ -1076,7 +1131,7 @@ where ); // `A` has progressed; update client on `B` with the latest header from `A`. - TypedRelayerOps::::update_client_on_a_with_sync( + TypedRelayerOps::::update_client_on_a_with_sync( ctx_b, ctx_a, client_id_on_b, diff --git a/ibc-testkit/src/testapp/ibc/clients/mod.rs b/ibc-testkit/src/testapp/ibc/clients/mod.rs index 05fe539daf..5598382ff7 100644 --- a/ibc-testkit/src/testapp/ibc/clients/mod.rs +++ b/ibc-testkit/src/testapp/ibc/clients/mod.rs @@ -15,8 +15,10 @@ use ibc::core::client::types::Height; use ibc::core::primitives::prelude::*; use ibc::derive::{ClientState, ConsensusState}; use ibc::primitives::proto::{Any, Protobuf}; +use mock::header::MockHeader; use super::core::types::MockIbcStore; +use crate::hosts::TestHeader; use crate::testapp::ibc::clients::mock::client_state::{ MockClientState, MOCK_CLIENT_STATE_TYPE_URL, }; @@ -24,9 +26,11 @@ use crate::testapp::ibc::clients::mock::consensus_state::{ MockConsensusState, MOCK_CONSENSUS_STATE_TYPE_URL, }; +type AnyMockIbcStore = MockIbcStore; + #[derive(Debug, Clone, From, PartialEq, ClientState)] -#[validation(MockIbcStore)] -#[execution(MockIbcStore)] +#[validation(AnyMockIbcStore)] +#[execution(AnyMockIbcStore)] pub enum AnyClientState { Tendermint(TmClientState), Mock(MockClientState), @@ -109,6 +113,12 @@ impl TryFrom for AnyConsensusState { } } +impl Default for AnyConsensusState { + fn default() -> Self { + Self::Mock(MockHeader::default().into_consensus_state()) + } +} + impl From for Any { fn from(host_consensus_state: AnyConsensusState) -> Self { match host_consensus_state { diff --git a/ibc-testkit/src/testapp/ibc/core/client_ctx.rs b/ibc-testkit/src/testapp/ibc/core/client_ctx.rs index 8c7bd8dd29..f686a55618 100644 --- a/ibc-testkit/src/testapp/ibc/core/client_ctx.rs +++ b/ibc-testkit/src/testapp/ibc/core/client_ctx.rs @@ -2,6 +2,8 @@ use core::fmt::Debug; use basecoin_store::context::{ProvableStore, Store}; use basecoin_store::types::Height as StoreHeight; +use ibc::core::client::context::client_state::{ClientStateExecution, ClientStateValidation}; +use ibc::core::client::context::consensus_state::ConsensusState; use ibc::core::client::context::{ ClientExecutionContext, ClientValidationContext, ExtClientValidationContext, }; @@ -18,24 +20,25 @@ use ibc::primitives::prelude::*; use super::types::MockIbcStore; use crate::testapp::ibc::clients::mock::client_state::MockClientContext; -use crate::testapp::ibc::clients::{AnyClientState, AnyConsensusState}; pub type PortChannelIdMap = BTreeMap>; /// A mock of an IBC client record as it is stored in a mock context. /// For testing ICS02 handlers mostly, cf. `MockClientContext`. #[derive(Clone, Debug)] -pub struct MockClientRecord { +pub struct MockClientRecord { /// The client state (representing only the latest height at the moment). - pub client_state: Option, + pub client_state: Option, /// Mapping of heights to consensus states for this client. - pub consensus_states: BTreeMap, + pub consensus_states: BTreeMap, } -impl MockClientContext for MockIbcStore +impl MockClientContext for MockIbcStore where S: ProvableStore + Debug, + ACL: ClientStateValidation + Clone, + ACS: ConsensusState + Clone, { fn host_timestamp(&self) -> Result { ValidationContext::host_timestamp(self) @@ -46,9 +49,11 @@ where } } -impl ExtClientValidationContext for MockIbcStore +impl ExtClientValidationContext for MockIbcStore where S: ProvableStore + Debug, + ACL: ClientStateValidation + Clone, + ACS: ConsensusState + Clone, { fn host_timestamp(&self) -> Result { ValidationContext::host_timestamp(self) @@ -152,12 +157,14 @@ where } } -impl ClientValidationContext for MockIbcStore +impl ClientValidationContext for MockIbcStore where S: ProvableStore + Debug, + ACL: ClientStateValidation + Clone, + ACS: ConsensusState + Clone, { - type ClientStateRef = AnyClientState; - type ConsensusStateRef = AnyConsensusState; + type ClientStateRef = ACL; + type ConsensusStateRef = ACS; fn client_state(&self, client_id: &ClientId) -> Result { Ok(self @@ -171,7 +178,7 @@ where fn consensus_state( &self, client_cons_state_path: &ClientConsensusStatePath, - ) -> Result { + ) -> Result { let height = Height::new( client_cons_state_path.revision_number, client_cons_state_path.revision_height, @@ -224,11 +231,13 @@ where } } -impl ClientExecutionContext for MockIbcStore +impl ClientExecutionContext for MockIbcStore where S: ProvableStore + Debug, + ACL: ClientStateExecution + Clone, + ACS: ConsensusState + Clone, { - type ClientStateMut = AnyClientState; + type ClientStateMut = ACL; /// Called upon successful client creation and update fn store_client_state( diff --git a/ibc-testkit/src/testapp/ibc/core/core_ctx.rs b/ibc-testkit/src/testapp/ibc/core/core_ctx.rs index d650cccd12..8468afde80 100644 --- a/ibc-testkit/src/testapp/ibc/core/core_ctx.rs +++ b/ibc-testkit/src/testapp/ibc/core/core_ctx.rs @@ -9,6 +9,7 @@ use ibc::core::channel::types::channel::{ChannelEnd, IdentifiedChannelEnd}; use ibc::core::channel::types::commitment::{AcknowledgementCommitment, PacketCommitment}; use ibc::core::channel::types::error::{ChannelError, PacketError}; use ibc::core::channel::types::packet::{PacketState, Receipt}; +use ibc::core::client::context::client_state::{ClientStateExecution, ClientStateValidation}; use ibc::core::client::context::consensus_state::ConsensusState; use ibc::core::client::types::error::ClientError; use ibc::core::client::types::Height; @@ -32,15 +33,16 @@ use ibc_proto::ibc::core::commitment::v1::MerkleProof as RawMerkleProof; use ibc_query::core::context::{ProvableContext, QueryContext}; use super::types::{MockIbcStore, DEFAULT_BLOCK_TIME_SECS}; -use crate::testapp::ibc::clients::{AnyClientState, AnyConsensusState}; -impl ValidationContext for MockIbcStore +impl ValidationContext for MockIbcStore where S: ProvableStore + Debug, + ACL: ClientStateValidation + Clone, + ACS: ConsensusState + Clone, { type V = Self; - type HostClientState = AnyClientState; - type HostConsensusState = AnyConsensusState; + type HostClientState = ACL; + type HostConsensusState = ACS; fn host_height(&self) -> Result { Ok(Height::new( @@ -79,7 +81,14 @@ where &self, client_state_of_host_on_counterparty: Self::HostClientState, ) -> Result<(), ContextError> { - if client_state_of_host_on_counterparty.is_frozen() { + // TODO(rano): simplify the status method. The client id is not needed here as the client state is at remote chain. + // We use a nonexisting client id to be able to call this method. + // Note, this will never return `Status::Active` and in happy cases it will return `Status::Expired` as + // the client state will not be found. + if client_state_of_host_on_counterparty + .status(self, &ClientId::new("nonexisting", 999).expect("no error"))? + .is_frozen() + { return Err(ClientError::ClientFrozen { description: String::new(), } @@ -269,9 +278,11 @@ where } /// Trait to provide proofs in gRPC service blanket implementations. -impl ProvableContext for MockIbcStore +impl ProvableContext for MockIbcStore where S: ProvableStore + Debug, + ACL: ClientStateValidation + Clone, + ACS: ConsensusState + Clone, { /// Returns the proof for the given [`Height`] and [`Path`] fn get_proof(&self, height: Height, path: &Path) -> Option> { @@ -294,9 +305,11 @@ where } /// Trait to complete the gRPC service blanket implementations. -impl QueryContext for MockIbcStore +impl QueryContext for MockIbcStore where S: ProvableStore + Debug, + ACL: ClientStateValidation + Clone, + ACS: ConsensusState + Clone, { /// Returns the list of all client states. fn client_states(&self) -> Result)>, ContextError> { @@ -636,9 +649,11 @@ where } } -impl ExecutionContext for MockIbcStore +impl ExecutionContext for MockIbcStore where S: ProvableStore + Debug, + ACL: ClientStateExecution + Clone, + ACS: ConsensusState + Clone, { type E = Self; diff --git a/ibc-testkit/src/testapp/ibc/core/types.rs b/ibc-testkit/src/testapp/ibc/core/types.rs index a1296cf6a3..45afbdbf9c 100644 --- a/ibc-testkit/src/testapp/ibc/core/types.rs +++ b/ibc-testkit/src/testapp/ibc/core/types.rs @@ -8,7 +8,10 @@ use basecoin_store::impls::SharedStore; use basecoin_store::types::{BinStore, JsonStore, ProtobufStore, TypedSet, TypedStore}; use ibc::core::channel::types::channel::ChannelEnd; use ibc::core::channel::types::commitment::{AcknowledgementCommitment, PacketCommitment}; -use ibc::core::client::context::client_state::ClientStateValidation; +use ibc::core::client::context::client_state::{ClientStateExecution, ClientStateValidation}; +use ibc::core::client::context::consensus_state::ConsensusState; +use ibc::core::client::context::ClientExecutionContext; +use ibc::core::client::types::error::ClientError; use ibc::core::client::types::Height; use ibc::core::connection::types::ConnectionEnd; use ibc::core::handler::types::events::IbcEvent; @@ -29,18 +32,17 @@ use ibc_proto::ics23::CommitmentProof; use parking_lot::Mutex; use typed_builder::TypedBuilder; -use crate::context::{MockStore, TestContext}; +use crate::context::{MockStore, StoreGenericTestContext}; use crate::fixtures::core::context::TestContextConfig; -use crate::hosts::{HostClientState, TestBlock, TestHeader, TestHost}; -use crate::testapp::ibc::clients::mock::header::MockHeader; +use crate::hosts::{HostClientState, HostConsensusState, TestBlock, TestHeader, TestHost}; use crate::testapp::ibc::clients::{AnyClientState, AnyConsensusState}; pub const DEFAULT_BLOCK_TIME_SECS: u64 = 3; -pub type DefaultIbcStore = MockIbcStore; +pub type DefaultIbcStore = MockIbcStore; /// An object that stores all IBC related data. #[derive(Debug)] -pub struct MockIbcStore +pub struct MockIbcStore where S: ProvableStore + Debug, { @@ -62,10 +64,9 @@ where pub client_processed_heights: ProtobufStore, ClientUpdateHeightPath, Height, RawHeight>, /// A typed-store for AnyClientState - pub client_state_store: ProtobufStore, ClientStatePath, AnyClientState, Any>, + pub client_state_store: ProtobufStore, ClientStatePath, ACL, Any>, /// A typed-store for AnyConsensusState - pub consensus_state_store: - ProtobufStore, ClientConsensusStatePath, AnyConsensusState, Any>, + pub consensus_state_store: ProtobufStore, ClientConsensusStatePath, ACS, Any>, /// A typed-store for ConnectionEnd pub connection_end_store: ProtobufStore, ConnectionPath, ConnectionEnd, RawConnectionEnd>, @@ -86,7 +87,7 @@ where /// A typed-store for packet ack pub packet_ack_store: BinStore, AckPath, AcknowledgementCommitment>, /// Map of host consensus states - pub host_consensus_states: Arc>>, + pub host_consensus_states: Arc>>, /// Map of older ibc commitment proofs pub ibc_commiment_proofs: Arc>>, /// IBC Events @@ -95,9 +96,11 @@ where pub logs: Arc>>, } -impl MockIbcStore +impl MockIbcStore where S: ProvableStore + Debug, + ACL: ClientStateValidation + Clone, + ACS: ConsensusState + Clone, { pub fn new(revision_number: u64, store: S) -> Self { let shared_store = SharedStore::new(store); @@ -144,7 +147,7 @@ where } } - fn store_host_consensus_state(&mut self, height: u64, consensus_state: AnyConsensusState) { + fn store_host_consensus_state(&mut self, height: u64, consensus_state: ACS) { self.host_consensus_states .lock() .insert(height, consensus_state); @@ -154,12 +157,7 @@ where self.ibc_commiment_proofs.lock().insert(height, proof); } - pub fn begin_block( - &mut self, - height: u64, - consensus_state: AnyConsensusState, - proof: CommitmentProof, - ) { + pub fn begin_block(&mut self, height: u64, consensus_state: ACS, proof: CommitmentProof) { assert_eq!(self.store.current_height(), height); self.store_host_consensus_state(height, consensus_state); self.store_ibc_commitment_proof(height, proof); @@ -178,18 +176,16 @@ where } } -impl Default for MockIbcStore +impl Default for MockIbcStore where S: ProvableStore + Debug + Default, + ACL: ClientStateValidation + Clone, + ACS: ConsensusState + Clone + Default, { fn default() -> Self { - // Note: this creates a MockIbcStore which has MockConsensusState as Host ConsensusState let mut ibc_store = Self::new(0, S::default()); ibc_store.store.commit().expect("no error"); - ibc_store.store_host_consensus_state( - ibc_store.store.current_height(), - MockHeader::default().into_consensus_state().into(), - ); + ibc_store.store_host_consensus_state(ibc_store.store.current_height(), ACS::default()); ibc_store.store_ibc_commitment_proof( ibc_store.store.current_height(), CommitmentProof::default(), @@ -443,56 +439,84 @@ mod tests { } } -pub struct LightClientState { +pub struct LightClientState +where + H: TestHost, + S: ProvableStore + Debug, +{ pub client_state: H::ClientState, pub consensus_states: BTreeMap::Header as TestHeader>::ConsensusState>, + pub _phantom: core::marker::PhantomData<(S, ACL, ACS)>, } -impl Default for LightClientState +impl Default for LightClientState where H: TestHost, - HostClientState: ClientStateValidation, + S: ProvableStore + Debug + Default, + ACL: From> + ClientStateExecution> + Clone, + ACS: From> + ConsensusState + Clone, + HostClientState: ClientStateValidation>, + MockIbcStore: + ClientExecutionContext, + ClientError: From<>::Error>, { fn default() -> Self { - let context = TestContext::::default(); + // we are using `MockStore` here as we discard the context after building the light client. + let context = StoreGenericTestContext::::default(); LightClientBuilder::init().context(&context).build() } } -impl LightClientState +impl LightClientState where H: TestHost, - HostClientState: ClientStateValidation, + S: ProvableStore + Debug + Default, + ACL: From> + ClientStateExecution> + Clone, + ACS: From> + ConsensusState + Clone, + HostClientState: ClientStateValidation>, + MockIbcStore: + ClientExecutionContext, + ClientError: From<>::Error>, { pub fn with_latest_height(height: Height) -> Self { let context = TestContextConfig::builder() .latest_height(height) - .build::>(); + .build::>(); LightClientBuilder::init().context(&context).build() } } #[derive(TypedBuilder)] #[builder(builder_method(name = init), build_method(into))] -pub struct LightClientBuilder<'a, H> +pub struct LightClientBuilder<'a, H, S, ACL, ACS> where H: TestHost, - HostClientState: ClientStateValidation, + S: ProvableStore + Debug, + ACL: From> + ClientStateExecution> + Clone, + ACS: From> + ConsensusState + Clone, + HostClientState: ClientStateValidation>, { - context: &'a TestContext, + context: &'a StoreGenericTestContext, #[builder(default, setter(into))] consensus_heights: Vec, #[builder(default)] params: H::LightClientParams, } -impl<'a, H> From> for LightClientState +impl<'a, H, S, ACL, ACS> From> + for LightClientState where H: TestHost, - HostClientState: ClientStateValidation, + S: ProvableStore + Debug, + ACL: From> + ClientStateExecution> + Clone, + ACS: From> + ConsensusState + Clone, + HostClientState: ClientStateValidation>, + MockIbcStore: + ClientExecutionContext, + ClientError: From<>::Error>, { - fn from(builder: LightClientBuilder<'a, H>) -> Self { + fn from(builder: LightClientBuilder<'a, H, S, ACL, ACS>) -> Self { let LightClientBuilder { context, consensus_heights, diff --git a/tests-integration/tests/core/ics02_client/create_client.rs b/tests-integration/tests/core/ics02_client/create_client.rs index 4e5dd9e770..8538ba1416 100644 --- a/tests-integration/tests/core/ics02_client/create_client.rs +++ b/tests-integration/tests/core/ics02_client/create_client.rs @@ -1,4 +1,3 @@ -use basecoin_store::impls::InMemoryStore; use ibc::clients::tendermint::types::{ client_type as tm_client_type, ConsensusState as TmConsensusState, }; @@ -28,7 +27,7 @@ use ibc_testkit::testapp::ibc::clients::mock::consensus_state::MockConsensusStat use ibc_testkit::testapp::ibc::clients::mock::header::MockHeader; use ibc_testkit::testapp::ibc::clients::{AnyClientState, AnyConsensusState}; use ibc_testkit::testapp::ibc::core::router::MockRouter; -use ibc_testkit::testapp::ibc::core::types::{DefaultIbcStore, LightClientBuilder, MockIbcStore}; +use ibc_testkit::testapp::ibc::core::types::{DefaultIbcStore, LightClientBuilder}; use test_log::test; #[test] @@ -96,7 +95,7 @@ fn test_tm_create_client_ok() { assert!(res.is_ok(), "tendermint client execution happy path"); let expected_client_state = - ClientStateRef::>::try_from(msg.client_state).unwrap(); + ClientStateRef::::try_from(msg.client_state).unwrap(); assert_eq!(expected_client_state.client_type(), client_type); assert_eq!(ctx.client_state(&client_id).unwrap(), expected_client_state); } diff --git a/tests-integration/tests/core/ics02_client/update_client.rs b/tests-integration/tests/core/ics02_client/update_client.rs index d5f19f8eb0..97785afcf3 100644 --- a/tests-integration/tests/core/ics02_client/update_client.rs +++ b/tests-integration/tests/core/ics02_client/update_client.rs @@ -24,13 +24,13 @@ use ibc::core::host::ValidationContext; use ibc::core::primitives::Timestamp; use ibc::primitives::proto::Any; use ibc::primitives::ToVec; -use ibc_testkit::context::{MockContext, TendermintContext, TestContext}; +use ibc_testkit::context::{DefaultLightClientState, MockContext, TendermintContext, TestContext}; use ibc_testkit::fixtures::clients::tendermint::ClientStateConfig; use ibc_testkit::fixtures::core::context::TestContextConfig; use ibc_testkit::fixtures::core::signer::dummy_account_id; use ibc_testkit::hosts::tendermint::BlockParams; use ibc_testkit::hosts::{ - HostClientState, MockHost, TendermintHost, TestBlock, TestHeader, TestHost, + HostClientState, HostConsensusState, MockHost, TendermintHost, TestBlock, TestHeader, TestHost, }; use ibc_testkit::relayer::error::RelayerError; use ibc_testkit::testapp::ibc::clients::mock::client_state::{ @@ -38,11 +38,9 @@ use ibc_testkit::testapp::ibc::clients::mock::client_state::{ }; use ibc_testkit::testapp::ibc::clients::mock::header::MockHeader; use ibc_testkit::testapp::ibc::clients::mock::misbehaviour::Misbehaviour as MockMisbehaviour; -use ibc_testkit::testapp::ibc::clients::AnyConsensusState; +use ibc_testkit::testapp::ibc::clients::{AnyClientState, AnyConsensusState}; use ibc_testkit::testapp::ibc::core::router::MockRouter; -use ibc_testkit::testapp::ibc::core::types::{ - DefaultIbcStore, LightClientBuilder, LightClientState, MockIbcStore, -}; +use ibc_testkit::testapp::ibc::core::types::{DefaultIbcStore, LightClientBuilder, MockIbcStore}; use rstest::*; use tendermint_testgen::Validator as TestgenValidator; use tracing::debug; @@ -58,7 +56,7 @@ fn fixture() -> Fixture { let ctx = MockContext::default().with_light_client( &client_id, - LightClientState::::with_latest_height(Height::new(0, 42).unwrap()), + DefaultLightClientState::::with_latest_height(Height::new(0, 42).unwrap()), ); let router = MockRouter::new_with_transfer(); @@ -1153,7 +1151,7 @@ fn test_update_client_events(fixture: Fixture) { } fn ensure_misbehaviour( - ctx: &MockIbcStore, + ctx: &MockIbcStore, client_id: &ClientId, client_type: &ClientType, ) { @@ -1209,7 +1207,7 @@ fn test_submit_misbehaviour_nonexisting_client(fixture: Fixture) { let ctx = MockContext::default().with_light_client( &client_id, - LightClientState::::with_latest_height(Height::new(0, 42).unwrap()), + DefaultLightClientState::::with_latest_height(Height::new(0, 42).unwrap()), ); let res = validate(&ctx.ibc_store, &router, msg_envelope); assert!(res.is_err()); @@ -1225,7 +1223,7 @@ fn test_client_update_misbehaviour_nonexisting_client(fixture: Fixture) { let ctx = MockContext::default().with_light_client( &client_id, - LightClientState::::with_latest_height(Height::new(0, 42).unwrap()), + DefaultLightClientState::::with_latest_height(Height::new(0, 42).unwrap()), ); let res = validate(&ctx.ibc_store, &router, msg_envelope); assert!(res.is_err()); @@ -1530,6 +1528,8 @@ pub(crate) fn build_client_update_datagram( src_header: &H, ) -> Result where + AnyClientState: From>, + AnyConsensusState: From>, HostClientState: ClientStateValidation, { // Check if client for ibc0 on ibc1 has been updated to latest height: diff --git a/tests-integration/tests/core/ics02_client/upgrade_client.rs b/tests-integration/tests/core/ics02_client/upgrade_client.rs index 015bf8921f..61c865a71d 100644 --- a/tests-integration/tests/core/ics02_client/upgrade_client.rs +++ b/tests-integration/tests/core/ics02_client/upgrade_client.rs @@ -8,7 +8,7 @@ use ibc::core::handler::types::error::ContextError; use ibc::core::handler::types::events::{IbcEvent, MessageEvent}; use ibc::core::handler::types::msgs::MsgEnvelope; use ibc::core::host::types::path::ClientConsensusStatePath; -use ibc_testkit::context::MockContext; +use ibc_testkit::context::{DefaultLightClientState, MockContext}; use ibc_testkit::fixtures::clients::tendermint::{ dummy_tendermint_header, dummy_tm_client_state_from_header, }; @@ -18,7 +18,6 @@ use ibc_testkit::hosts::MockHost; use ibc_testkit::testapp::ibc::clients::mock::client_state::client_type as mock_client_type; use ibc_testkit::testapp::ibc::clients::{AnyClientState, AnyConsensusState}; use ibc_testkit::testapp::ibc::core::router::MockRouter; -use ibc_testkit::testapp::ibc::core::types::LightClientState; enum Ctx { Default, @@ -37,7 +36,7 @@ fn msg_upgrade_client_fixture(ctx_variant: Ctx, msg_variant: Msg) -> Fixture::with_latest_height(Height::new(0, 42).unwrap()), + DefaultLightClientState::::with_latest_height(Height::new(0, 42).unwrap()), ); let ctx = match ctx_variant { Ctx::Default => ctx_default.ibc_store, diff --git a/tests-integration/tests/core/ics03_connection/conn_open_ack.rs b/tests-integration/tests/core/ics03_connection/conn_open_ack.rs index 8860e32279..0a59414f28 100644 --- a/tests-integration/tests/core/ics03_connection/conn_open_ack.rs +++ b/tests-integration/tests/core/ics03_connection/conn_open_ack.rs @@ -13,13 +13,13 @@ use ibc::core::host::types::identifiers::{ChainId, ClientId}; use ibc::core::host::ValidationContext; use ibc::core::primitives::prelude::*; use ibc::core::primitives::ZERO_DURATION; -use ibc_testkit::context::MockContext; +use ibc_testkit::context::{DefaultLightClientState, MockContext}; use ibc_testkit::fixtures::core::connection::dummy_msg_conn_open_ack; use ibc_testkit::fixtures::core::context::TestContextConfig; use ibc_testkit::fixtures::{Expect, Fixture}; use ibc_testkit::hosts::MockHost; use ibc_testkit::testapp::ibc::core::router::MockRouter; -use ibc_testkit::testapp::ibc::core::types::{DefaultIbcStore, LightClientState}; +use ibc_testkit::testapp::ibc::core::types::DefaultIbcStore; use test_log::test; enum Ctx { @@ -76,7 +76,7 @@ fn conn_open_ack_fixture(ctx: Ctx) -> Fixture { ctx_new .with_light_client( &client_id, - LightClientState::::with_latest_height(proof_height), + DefaultLightClientState::::with_latest_height(proof_height), ) .with_connection(conn_id, default_conn_end) .ibc_store @@ -85,7 +85,7 @@ fn conn_open_ack_fixture(ctx: Ctx) -> Fixture { ctx_default .with_light_client( &client_id, - LightClientState::::with_latest_height(proof_height), + DefaultLightClientState::::with_latest_height(proof_height), ) .with_connection(conn_id, default_conn_end) .ibc_store @@ -94,7 +94,7 @@ fn conn_open_ack_fixture(ctx: Ctx) -> Fixture { ctx_new .with_light_client( &client_id, - LightClientState::::with_latest_height(proof_height), + DefaultLightClientState::::with_latest_height(proof_height), ) .with_connection(conn_id, conn_end_open) .ibc_store diff --git a/tests-integration/tests/core/ics03_connection/conn_open_confirm.rs b/tests-integration/tests/core/ics03_connection/conn_open_confirm.rs index dc21dadefc..7c1cc9f820 100644 --- a/tests-integration/tests/core/ics03_connection/conn_open_confirm.rs +++ b/tests-integration/tests/core/ics03_connection/conn_open_confirm.rs @@ -11,12 +11,11 @@ use ibc::core::host::types::identifiers::ClientId; use ibc::core::host::ValidationContext; use ibc::core::primitives::prelude::*; use ibc::core::primitives::ZERO_DURATION; -use ibc_testkit::context::MockContext; +use ibc_testkit::context::{DefaultLightClientState, MockContext}; use ibc_testkit::fixtures::core::connection::dummy_conn_open_confirm; use ibc_testkit::fixtures::{Expect, Fixture}; use ibc_testkit::hosts::MockHost; use ibc_testkit::testapp::ibc::core::router::MockRouter; -use ibc_testkit::testapp::ibc::core::types::LightClientState; use test_log::test; enum Ctx { @@ -54,7 +53,9 @@ fn conn_open_confirm_fixture(ctx: Ctx) -> Fixture { ctx_default .with_light_client( &client_id, - LightClientState::::with_latest_height(Height::new(0, 10).unwrap()), + DefaultLightClientState::::with_latest_height( + Height::new(0, 10).unwrap(), + ), ) .with_connection(msg.conn_id_on_b.clone(), incorrect_conn_end_state) .ibc_store @@ -63,7 +64,9 @@ fn conn_open_confirm_fixture(ctx: Ctx) -> Fixture { ctx_default .with_light_client( &client_id, - LightClientState::::with_latest_height(Height::new(0, 10).unwrap()), + DefaultLightClientState::::with_latest_height( + Height::new(0, 10).unwrap(), + ), ) .with_connection(msg.conn_id_on_b.clone(), correct_conn_end) .ibc_store diff --git a/tests-integration/tests/core/ics03_connection/conn_open_init.rs b/tests-integration/tests/core/ics03_connection/conn_open_init.rs index 1a9218e24f..635100c9db 100644 --- a/tests-integration/tests/core/ics03_connection/conn_open_init.rs +++ b/tests-integration/tests/core/ics03_connection/conn_open_init.rs @@ -7,7 +7,7 @@ use ibc::core::handler::types::events::{IbcEvent, MessageEvent}; use ibc::core::handler::types::msgs::MsgEnvelope; use ibc::core::host::ValidationContext; use ibc::core::primitives::prelude::*; -use ibc_testkit::context::MockContext; +use ibc_testkit::context::{DefaultLightClientState, MockContext}; use ibc_testkit::fixtures::core::connection::{ dummy_msg_conn_open_init, msg_conn_open_init_with_counterparty_conn_id, msg_conn_open_with_version, @@ -15,7 +15,6 @@ use ibc_testkit::fixtures::core::connection::{ use ibc_testkit::fixtures::{Expect, Fixture}; use ibc_testkit::hosts::MockHost; use ibc_testkit::testapp::ibc::core::router::MockRouter; -use ibc_testkit::testapp::ibc::core::types::LightClientState; use test_log::test; enum Ctx { @@ -47,7 +46,9 @@ fn conn_open_init_fixture(ctx_variant: Ctx, msg_variant: Msg) -> Fixture::with_latest_height(Height::new(0, 10).unwrap()), + DefaultLightClientState::::with_latest_height( + Height::new(0, 10).unwrap(), + ), ) .ibc_store } diff --git a/tests-integration/tests/core/ics03_connection/conn_open_try.rs b/tests-integration/tests/core/ics03_connection/conn_open_try.rs index e466b403d6..cca06c0d54 100644 --- a/tests-integration/tests/core/ics03_connection/conn_open_try.rs +++ b/tests-integration/tests/core/ics03_connection/conn_open_try.rs @@ -6,13 +6,13 @@ use ibc::core::handler::types::events::{IbcEvent, MessageEvent}; use ibc::core::handler::types::msgs::MsgEnvelope; use ibc::core::host::ValidationContext; use ibc::core::primitives::prelude::*; -use ibc_testkit::context::MockContext; +use ibc_testkit::context::{DefaultLightClientState, MockContext}; use ibc_testkit::fixtures::core::connection::dummy_msg_conn_open_try; use ibc_testkit::fixtures::core::context::TestContextConfig; use ibc_testkit::fixtures::{Expect, Fixture}; use ibc_testkit::hosts::MockHost; use ibc_testkit::testapp::ibc::core::router::MockRouter; -use ibc_testkit::testapp::ibc::core::types::{DefaultIbcStore, LightClientState}; +use ibc_testkit::testapp::ibc::core::types::DefaultIbcStore; use test_log::test; enum Ctx { @@ -60,7 +60,7 @@ fn conn_open_try_fixture(ctx_variant: Ctx, msg_variant: Msg) -> Fixture::with_latest_height( + DefaultLightClientState::::with_latest_height( Height::new(0, client_cons_state_height).unwrap(), ), ) diff --git a/tests-integration/tests/core/ics04_channel/acknowledgement.rs b/tests-integration/tests/core/ics04_channel/acknowledgement.rs index 1afd22fe17..f1fab14562 100644 --- a/tests-integration/tests/core/ics04_channel/acknowledgement.rs +++ b/tests-integration/tests/core/ics04_channel/acknowledgement.rs @@ -13,11 +13,10 @@ use ibc::core::handler::types::events::{IbcEvent, MessageEvent}; use ibc::core::handler::types::msgs::MsgEnvelope; use ibc::core::host::types::identifiers::{ChannelId, ClientId, ConnectionId, PortId}; use ibc::core::primitives::*; -use ibc_testkit::context::MockContext; +use ibc_testkit::context::{DefaultLightClientState, MockContext}; use ibc_testkit::fixtures::core::channel::dummy_raw_msg_acknowledgement; use ibc_testkit::hosts::MockHost; use ibc_testkit::testapp::ibc::core::router::MockRouter; -use ibc_testkit::testapp::ibc::core::types::LightClientState; use rstest::*; use test_log::test; @@ -39,7 +38,7 @@ fn fixture() -> Fixture { let client_height = Height::new(0, 2).unwrap(); let ctx = MockContext::default().with_light_client( &ClientId::new("07-tendermint", 0).expect("no error"), - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ); let router = MockRouter::new_with_transfer(); @@ -125,7 +124,7 @@ fn ack_success_no_packet_commitment(fixture: Fixture) { let ctx = ctx .with_light_client( &ClientId::new("07-tendermint", 0).expect("no error"), - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ) .with_channel( PortId::transfer(), @@ -159,7 +158,7 @@ fn ack_success_happy_path(fixture: Fixture) { let ctx = ctx .with_light_client( &ClientId::new("07-tendermint", 0).expect("no error"), - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ) .with_channel( PortId::transfer(), diff --git a/tests-integration/tests/core/ics04_channel/chan_close_confirm.rs b/tests-integration/tests/core/ics04_channel/chan_close_confirm.rs index f3491f9ca6..e4593fd0cb 100644 --- a/tests-integration/tests/core/ics04_channel/chan_close_confirm.rs +++ b/tests-integration/tests/core/ics04_channel/chan_close_confirm.rs @@ -11,13 +11,12 @@ use ibc::core::handler::types::msgs::MsgEnvelope; use ibc::core::host::types::identifiers::ConnectionId; use ibc::core::host::ValidationContext; use ibc::core::primitives::*; -use ibc_testkit::context::MockContext; +use ibc_testkit::context::{DefaultLightClientState, MockContext}; use ibc_testkit::fixtures::core::channel::dummy_raw_msg_chan_close_confirm; use ibc_testkit::fixtures::core::connection::dummy_raw_counterparty_conn; use ibc_testkit::hosts::MockHost; use ibc_testkit::testapp::ibc::clients::mock::client_state::client_type as mock_client_type; use ibc_testkit::testapp::ibc::core::router::MockRouter; -use ibc_testkit::testapp::ibc::core::types::LightClientState; #[test] fn test_chan_close_confirm_validate() { @@ -57,7 +56,7 @@ fn test_chan_close_confirm_validate() { let context = default_context .with_light_client( &client_id, - LightClientState::::with_latest_height(client_consensus_state_height), + DefaultLightClientState::::with_latest_height(client_consensus_state_height), ) .with_connection(conn_id, conn_end) .with_channel( @@ -114,7 +113,7 @@ fn test_chan_close_confirm_execute() { let mut context = default_context .with_light_client( &client_id, - LightClientState::::with_latest_height(client_consensus_state_height), + DefaultLightClientState::::with_latest_height(client_consensus_state_height), ) .with_connection(conn_id, conn_end) .with_channel( diff --git a/tests-integration/tests/core/ics04_channel/chan_close_init.rs b/tests-integration/tests/core/ics04_channel/chan_close_init.rs index 63fd30d656..b35f146c36 100644 --- a/tests-integration/tests/core/ics04_channel/chan_close_init.rs +++ b/tests-integration/tests/core/ics04_channel/chan_close_init.rs @@ -11,13 +11,12 @@ use ibc::core::handler::types::msgs::MsgEnvelope; use ibc::core::host::types::identifiers::ConnectionId; use ibc::core::host::ValidationContext; use ibc::core::primitives::*; -use ibc_testkit::context::MockContext; +use ibc_testkit::context::{DefaultLightClientState, MockContext}; use ibc_testkit::fixtures::core::channel::dummy_raw_msg_chan_close_init; use ibc_testkit::fixtures::core::connection::dummy_raw_counterparty_conn; use ibc_testkit::hosts::MockHost; use ibc_testkit::testapp::ibc::clients::mock::client_state::client_type as mock_client_type; use ibc_testkit::testapp::ibc::core::router::MockRouter; -use ibc_testkit::testapp::ibc::core::types::LightClientState; #[test] fn test_chan_close_init_validate() { @@ -57,7 +56,9 @@ fn test_chan_close_init_validate() { default_context .with_light_client( &client_id, - LightClientState::::with_latest_height(client_consensus_state_height), + DefaultLightClientState::::with_latest_height( + client_consensus_state_height, + ), ) .with_connection(conn_id, conn_end) .with_channel( @@ -115,7 +116,9 @@ fn test_chan_close_init_execute() { default_context .with_light_client( &client_id, - LightClientState::::with_latest_height(client_consensus_state_height), + DefaultLightClientState::::with_latest_height( + client_consensus_state_height, + ), ) .with_connection(conn_id, conn_end) .with_channel( diff --git a/tests-integration/tests/core/ics04_channel/chan_open_ack.rs b/tests-integration/tests/core/ics04_channel/chan_open_ack.rs index e4250dd83a..d3ec9e2940 100644 --- a/tests-integration/tests/core/ics04_channel/chan_open_ack.rs +++ b/tests-integration/tests/core/ics04_channel/chan_open_ack.rs @@ -12,13 +12,12 @@ use ibc::core::handler::types::msgs::MsgEnvelope; use ibc::core::host::types::identifiers::{ClientId, ConnectionId}; use ibc::core::primitives::*; use ibc::core::router::types::module::ModuleId; -use ibc_testkit::context::MockContext; +use ibc_testkit::context::{DefaultLightClientState, MockContext}; use ibc_testkit::fixtures::core::channel::dummy_raw_msg_chan_open_ack; use ibc_testkit::fixtures::core::connection::dummy_raw_counterparty_conn; use ibc_testkit::hosts::MockHost; use ibc_testkit::testapp::ibc::clients::mock::client_state::client_type as mock_client_type; use ibc_testkit::testapp::ibc::core::router::MockRouter; -use ibc_testkit::testapp::ibc::core::types::LightClientState; use rstest::*; use test_log::test; @@ -94,7 +93,9 @@ fn chan_open_ack_happy_path(fixture: Fixture) { let context = context .with_light_client( &client_id_on_a, - LightClientState::::with_latest_height(Height::new(0, proof_height).unwrap()), + DefaultLightClientState::::with_latest_height( + Height::new(0, proof_height).unwrap(), + ), ) .with_connection(conn_id_on_a, conn_end_on_a) .with_channel( @@ -127,7 +128,9 @@ fn chan_open_ack_execute_happy_path(fixture: Fixture) { let mut context = context .with_light_client( &client_id_on_a, - LightClientState::::with_latest_height(Height::new(0, proof_height).unwrap()), + DefaultLightClientState::::with_latest_height( + Height::new(0, proof_height).unwrap(), + ), ) .with_connection(conn_id_on_a, conn_end_on_a) .with_channel( @@ -167,7 +170,9 @@ fn chan_open_ack_fail_no_connection(fixture: Fixture) { let context = context .with_light_client( &client_id_on_a, - LightClientState::::with_latest_height(Height::new(0, proof_height).unwrap()), + DefaultLightClientState::::with_latest_height( + Height::new(0, proof_height).unwrap(), + ), ) .with_channel( msg.port_id_on_a.clone(), @@ -200,7 +205,9 @@ fn chan_open_ack_fail_no_channel(fixture: Fixture) { let context = context .with_light_client( &client_id_on_a, - LightClientState::::with_latest_height(Height::new(0, proof_height).unwrap()), + DefaultLightClientState::::with_latest_height( + Height::new(0, proof_height).unwrap(), + ), ) .with_connection(conn_id_on_a, conn_end_on_a); @@ -238,7 +245,9 @@ fn chan_open_ack_fail_channel_wrong_state(fixture: Fixture) { let context = context .with_light_client( &client_id_on_a, - LightClientState::::with_latest_height(Height::new(0, proof_height).unwrap()), + DefaultLightClientState::::with_latest_height( + Height::new(0, proof_height).unwrap(), + ), ) .with_connection(conn_id_on_a, conn_end_on_a) .with_channel( diff --git a/tests-integration/tests/core/ics04_channel/chan_open_confirm.rs b/tests-integration/tests/core/ics04_channel/chan_open_confirm.rs index 0b399aa400..e84a72f621 100644 --- a/tests-integration/tests/core/ics04_channel/chan_open_confirm.rs +++ b/tests-integration/tests/core/ics04_channel/chan_open_confirm.rs @@ -11,13 +11,12 @@ use ibc::core::handler::types::events::{IbcEvent, MessageEvent}; use ibc::core::handler::types::msgs::MsgEnvelope; use ibc::core::host::types::identifiers::{ChannelId, ClientId, ConnectionId}; use ibc::core::primitives::*; -use ibc_testkit::context::MockContext; +use ibc_testkit::context::{DefaultLightClientState, MockContext}; use ibc_testkit::fixtures::core::channel::dummy_raw_msg_chan_open_confirm; use ibc_testkit::fixtures::core::connection::dummy_raw_counterparty_conn; use ibc_testkit::hosts::MockHost; use ibc_testkit::testapp::ibc::clients::mock::client_state::client_type as mock_client_type; use ibc_testkit::testapp::ibc::core::router::MockRouter; -use ibc_testkit::testapp::ibc::core::types::LightClientState; use rstest::*; use test_log::test; @@ -91,7 +90,9 @@ fn chan_open_confirm_validate_happy_path(fixture: Fixture) { let context = context .with_light_client( &client_id_on_b, - LightClientState::::with_latest_height(Height::new(0, proof_height).unwrap()), + DefaultLightClientState::::with_latest_height( + Height::new(0, proof_height).unwrap(), + ), ) .with_connection(conn_id_on_b, conn_end_on_b) .with_channel(msg.port_id_on_b.clone(), ChannelId::zero(), chan_end_on_b); @@ -120,7 +121,9 @@ fn chan_open_confirm_execute_happy_path(fixture: Fixture) { let mut context = context .with_light_client( &client_id_on_b, - LightClientState::::with_latest_height(Height::new(0, proof_height).unwrap()), + DefaultLightClientState::::with_latest_height( + Height::new(0, proof_height).unwrap(), + ), ) .with_connection(conn_id_on_b, conn_end_on_b) .with_channel(msg.port_id_on_b.clone(), ChannelId::zero(), chan_end_on_b); @@ -158,7 +161,9 @@ fn chan_open_confirm_fail_no_channel(fixture: Fixture) { let context = context .with_light_client( &client_id_on_b, - LightClientState::::with_latest_height(Height::new(0, proof_height).unwrap()), + DefaultLightClientState::::with_latest_height( + Height::new(0, proof_height).unwrap(), + ), ) .with_connection(conn_id_on_b, conn_end_on_b); @@ -196,7 +201,9 @@ fn chan_open_confirm_fail_channel_wrong_state(fixture: Fixture) { let context = context .with_light_client( &client_id_on_b, - LightClientState::::with_latest_height(Height::new(0, proof_height).unwrap()), + DefaultLightClientState::::with_latest_height( + Height::new(0, proof_height).unwrap(), + ), ) .with_connection(conn_id_on_b, conn_end_on_b) .with_channel(msg.port_id_on_b.clone(), ChannelId::zero(), wrong_chan_end); diff --git a/tests-integration/tests/core/ics04_channel/chan_open_init.rs b/tests-integration/tests/core/ics04_channel/chan_open_init.rs index 844af3d65c..93d12d3f9d 100644 --- a/tests-integration/tests/core/ics04_channel/chan_open_init.rs +++ b/tests-integration/tests/core/ics04_channel/chan_open_init.rs @@ -8,12 +8,12 @@ use ibc::core::handler::types::events::{IbcEvent, MessageEvent}; use ibc::core::handler::types::msgs::MsgEnvelope; use ibc::core::host::types::identifiers::ConnectionId; use ibc::core::host::ValidationContext; -use ibc_testkit::context::MockContext; +use ibc_testkit::context::{DefaultLightClientState, MockContext}; use ibc_testkit::fixtures::core::channel::dummy_raw_msg_chan_open_init; use ibc_testkit::fixtures::core::connection::dummy_msg_conn_open_init; use ibc_testkit::hosts::MockHost; use ibc_testkit::testapp::ibc::core::router::MockRouter; -use ibc_testkit::testapp::ibc::core::types::{DefaultIbcStore, LightClientState}; +use ibc_testkit::testapp::ibc::core::types::DefaultIbcStore; use rstest::*; use test_log::test; @@ -50,7 +50,7 @@ fn fixture() -> Fixture { let ctx = default_ctx .with_light_client( &client_id_on_a, - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ) .with_connection(ConnectionId::zero(), conn_end_on_a); diff --git a/tests-integration/tests/core/ics04_channel/chan_open_try.rs b/tests-integration/tests/core/ics04_channel/chan_open_try.rs index 3a43d0dfbd..38c2f108d7 100644 --- a/tests-integration/tests/core/ics04_channel/chan_open_try.rs +++ b/tests-integration/tests/core/ics04_channel/chan_open_try.rs @@ -10,13 +10,12 @@ use ibc::core::handler::types::msgs::MsgEnvelope; use ibc::core::host::types::identifiers::{ClientId, ConnectionId}; use ibc::core::host::ValidationContext; use ibc::core::primitives::*; -use ibc_testkit::context::MockContext; +use ibc_testkit::context::{DefaultLightClientState, MockContext}; use ibc_testkit::fixtures::core::channel::dummy_raw_msg_chan_open_try; use ibc_testkit::fixtures::core::connection::dummy_raw_counterparty_conn; use ibc_testkit::hosts::MockHost; use ibc_testkit::testapp::ibc::clients::mock::client_state::client_type as mock_client_type; use ibc_testkit::testapp::ibc::core::router::MockRouter; -use ibc_testkit::testapp::ibc::core::types::LightClientState; use rstest::*; use test_log::test; @@ -87,7 +86,9 @@ fn chan_open_try_validate_happy_path(fixture: Fixture) { let ctx = ctx .with_light_client( &client_id_on_b, - LightClientState::::with_latest_height(Height::new(0, proof_height).unwrap()), + DefaultLightClientState::::with_latest_height( + Height::new(0, proof_height).unwrap(), + ), ) .with_connection(conn_id_on_b, conn_end_on_b); @@ -112,7 +113,9 @@ fn chan_open_try_execute_happy_path(fixture: Fixture) { let mut ctx = ctx .with_light_client( &client_id_on_b, - LightClientState::::with_latest_height(Height::new(0, proof_height).unwrap()), + DefaultLightClientState::::with_latest_height( + Height::new(0, proof_height).unwrap(), + ), ) .with_connection(conn_id_on_b, conn_end_on_b); diff --git a/tests-integration/tests/core/ics04_channel/recv_packet.rs b/tests-integration/tests/core/ics04_channel/recv_packet.rs index df946f1e35..d895723bf2 100644 --- a/tests-integration/tests/core/ics04_channel/recv_packet.rs +++ b/tests-integration/tests/core/ics04_channel/recv_packet.rs @@ -13,12 +13,11 @@ use ibc::core::handler::types::events::{IbcEvent, MessageEvent}; use ibc::core::handler::types::msgs::MsgEnvelope; use ibc::core::host::types::identifiers::{ChannelId, ClientId, ConnectionId, PortId}; use ibc::core::primitives::*; -use ibc_testkit::context::MockContext; +use ibc_testkit::context::{DefaultLightClientState, MockContext}; use ibc_testkit::fixtures::core::channel::{dummy_msg_recv_packet, dummy_raw_msg_recv_packet}; use ibc_testkit::fixtures::core::signer::dummy_account_id; use ibc_testkit::hosts::MockHost; use ibc_testkit::testapp::ibc::core::router::MockRouter; -use ibc_testkit::testapp::ibc::core::types::LightClientState; use rstest::*; use test_log::test; @@ -120,7 +119,7 @@ fn recv_packet_validate_happy_path(fixture: Fixture) { let context = context .with_light_client( &ClientId::new("07-tendermint", 0).expect("no error"), - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ) .with_connection(ConnectionId::zero(), conn_end_on_b) .with_channel( @@ -187,7 +186,7 @@ fn recv_packet_timeout_expired(fixture: Fixture) { let context = context .with_light_client( &ClientId::new("07-tendermint", 0).expect("no error"), - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ) .with_connection(ConnectionId::zero(), conn_end_on_b) .with_channel(PortId::transfer(), ChannelId::zero(), chan_end_on_b) @@ -216,7 +215,7 @@ fn recv_packet_execute_happy_path(fixture: Fixture) { let mut ctx = context .with_light_client( &ClientId::new("07-tendermint", 0).expect("no error"), - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ) .with_connection(ConnectionId::zero(), conn_end_on_b) .with_channel(PortId::transfer(), ChannelId::zero(), chan_end_on_b); diff --git a/tests-integration/tests/core/ics04_channel/send_packet.rs b/tests-integration/tests/core/ics04_channel/send_packet.rs index 3a2bace448..4b227e90ea 100644 --- a/tests-integration/tests/core/ics04_channel/send_packet.rs +++ b/tests-integration/tests/core/ics04_channel/send_packet.rs @@ -15,10 +15,9 @@ use ibc::core::connection::types::{ use ibc::core::handler::types::events::{IbcEvent, MessageEvent}; use ibc::core::host::types::identifiers::{ChannelId, ClientId, ConnectionId, PortId}; use ibc::core::primitives::*; -use ibc_testkit::context::MockContext; +use ibc_testkit::context::{DefaultLightClientState, MockContext}; use ibc_testkit::fixtures::core::channel::dummy_raw_packet; use ibc_testkit::hosts::MockHost; -use ibc_testkit::testapp::ibc::core::types::LightClientState; use test_log::test; #[test] @@ -104,7 +103,7 @@ fn send_packet_processing() { ctx: MockContext::default() .with_light_client( &ClientId::new("07-tendermint", 0).expect("no error"), - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ) .with_connection(ConnectionId::zero(), conn_end_on_a.clone()) .with_channel(PortId::transfer(), ChannelId::zero(), chan_end_on_a.clone()) @@ -117,7 +116,7 @@ fn send_packet_processing() { ctx: MockContext::default() .with_light_client( &ClientId::new("07-tendermint", 0).expect("no error"), - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ) .with_connection(ConnectionId::zero(), conn_end_on_a.clone()) .with_channel(PortId::transfer(), ChannelId::zero(), chan_end_on_a.clone()) @@ -130,7 +129,7 @@ fn send_packet_processing() { ctx: MockContext::default() .with_light_client( &ClientId::new("07-tendermint", 0).expect("no error"), - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ) .with_connection(ConnectionId::zero(), conn_end_on_a.clone()) .with_channel(PortId::transfer(), ChannelId::zero(), chan_end_on_a.clone()) @@ -143,7 +142,7 @@ fn send_packet_processing() { ctx: MockContext::default() .with_light_client( &ClientId::new("07-tendermint", 0).expect("no error"), - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ) .with_connection(ConnectionId::zero(), conn_end_on_a.clone()) .with_channel(PortId::transfer(), ChannelId::zero(), chan_end_on_a.clone()) @@ -156,7 +155,7 @@ fn send_packet_processing() { ctx: MockContext::default() .with_light_client( &ClientId::new("07-tendermint", 0).expect("no error"), - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ) .with_connection(ConnectionId::zero(), conn_end_on_a) .with_channel(PortId::transfer(), ChannelId::zero(), chan_end_on_a) diff --git a/tests-integration/tests/core/ics04_channel/timeout.rs b/tests-integration/tests/core/ics04_channel/timeout.rs index 240ddd4a85..64297b723b 100644 --- a/tests-integration/tests/core/ics04_channel/timeout.rs +++ b/tests-integration/tests/core/ics04_channel/timeout.rs @@ -15,11 +15,10 @@ use ibc::core::handler::types::msgs::MsgEnvelope; use ibc::core::host::types::identifiers::{ChannelId, ClientId, ConnectionId, PortId}; use ibc::core::host::types::path::ClientConsensusStatePath; use ibc::core::primitives::*; -use ibc_testkit::context::MockContext; +use ibc_testkit::context::{DefaultLightClientState, MockContext}; use ibc_testkit::fixtures::core::channel::dummy_raw_msg_timeout; use ibc_testkit::hosts::MockHost; use ibc_testkit::testapp::ibc::core::router::MockRouter; -use ibc_testkit::testapp::ibc::core::types::LightClientState; use rstest::*; struct Fixture { @@ -41,7 +40,7 @@ fn fixture() -> Fixture { let client_height = Height::new(0, 2).unwrap(); let ctx = MockContext::default().with_light_client( &ClientId::new("07-tendermint", 0).expect("no error"), - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ); let client_height = Height::new(0, 2).unwrap(); @@ -117,7 +116,7 @@ fn timeout_fail_no_channel(fixture: Fixture) { } = fixture; let ctx = ctx.with_light_client( &ClientId::new("07-tendermint", 0).expect("no error"), - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ); let msg_envelope = MsgEnvelope::from(PacketMsg::from(msg)); let res = validate(&ctx.ibc_store, &router, msg_envelope); @@ -204,7 +203,7 @@ fn timeout_fail_proof_timeout_not_reached(fixture: Fixture) { let ctx = ctx .with_light_client( &ClientId::new("07-tendermint", 0).expect("no error"), - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ) .with_connection(ConnectionId::zero(), conn_end_on_a) .with_channel( @@ -276,7 +275,7 @@ fn timeout_unordered_channel_validate(fixture: Fixture) { let ctx = ctx .with_light_client( &ClientId::new("07-tendermint", 0).expect("no error"), - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ) .with_connection(ConnectionId::zero(), conn_end_on_a) .with_channel( @@ -316,7 +315,7 @@ fn timeout_ordered_channel_validate(fixture: Fixture) { let ctx = ctx .with_light_client( &ClientId::new("07-tendermint", 0).expect("no error"), - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ) .with_connection(ConnectionId::zero(), conn_end_on_a) .with_channel(PortId::transfer(), ChannelId::zero(), chan_end_on_a_ordered) diff --git a/tests-integration/tests/core/ics04_channel/timeout_on_close.rs b/tests-integration/tests/core/ics04_channel/timeout_on_close.rs index a454261fda..0bbe643588 100644 --- a/tests-integration/tests/core/ics04_channel/timeout_on_close.rs +++ b/tests-integration/tests/core/ics04_channel/timeout_on_close.rs @@ -12,11 +12,10 @@ use ibc::core::entrypoint::validate; use ibc::core::handler::types::msgs::MsgEnvelope; use ibc::core::host::types::identifiers::{ChannelId, ClientId, ConnectionId, PortId}; use ibc::core::primitives::*; -use ibc_testkit::context::MockContext; +use ibc_testkit::context::{DefaultLightClientState, MockContext}; use ibc_testkit::fixtures::core::channel::dummy_raw_msg_timeout_on_close; use ibc_testkit::hosts::MockHost; use ibc_testkit::testapp::ibc::core::router::MockRouter; -use ibc_testkit::testapp::ibc::core::types::LightClientState; use rstest::*; pub struct Fixture { @@ -35,7 +34,7 @@ fn fixture() -> Fixture { let client_height = Height::new(0, 2).unwrap(); let context = MockContext::default().with_light_client( &ClientId::new("07-tendermint", 0).expect("no error"), - LightClientState::::with_latest_height(client_height), + DefaultLightClientState::::with_latest_height(client_height), ); let router = MockRouter::new_with_transfer();