From a626d39b3fd590c997df7a2c4c9012a261472ba4 Mon Sep 17 00:00:00 2001 From: livelybug Date: Wed, 30 Mar 2022 16:07:40 +0800 Subject: [PATCH] Update unit test --- modules/src/mock/context.rs | 12 +++++++++--- relayer/src/foreign_client.rs | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/modules/src/mock/context.rs b/modules/src/mock/context.rs index 66ba59688..256dc53e0 100644 --- a/modules/src/mock/context.rs +++ b/modules/src/mock/context.rs @@ -44,6 +44,7 @@ use crate::relayer::ics18_relayer::error::Error as Ics18Error; use crate::signer::Signer; use crate::timestamp::Timestamp; use crate::Height; +use crate::clients::ics10_grandpa::{client_state::ClientState, consensus_state::ConsensusState}; pub const DEFAULT_BLOCK_TIME_SECS: u64 = 3; @@ -284,7 +285,6 @@ impl MockContext { Some(MockClientState::new(MockHeader::new(client_state_height)).into()), MockConsensusState::new(MockHeader::new(cs_height)).into(), ), - ClientType::Grandpa => todo!(), // If it's a Tendermint client, we need TM states. ClientType::Tendermint => { let light_block = HostBlock::generate_tm_block( @@ -300,12 +300,16 @@ impl MockContext { // Return the tuple. (Some(client_state), consensus_state) } + ClientType::Grandpa => { + let client_state = AnyClientState::Grandpa(ClientState::default()); + let consensus_state = AnyConsensusState::Grandpa(ConsensusState::default()); + (Some(client_state), consensus_state) + }, }; let prev_consensus_state = match client_type { // If it's a mock client, create the corresponding mock states. ClientType::Mock => MockConsensusState::new(MockHeader::new(prev_cs_height)).into(), - ClientType::Grandpa => todo!(), // If it's a Tendermint client, we need TM states. ClientType::Tendermint => { let light_block = HostBlock::generate_tm_block( @@ -315,6 +319,7 @@ impl MockContext { ); AnyConsensusState::from(light_block) } + ClientType::Grandpa => AnyConsensusState::Grandpa(ConsensusState::default()), }; let consensus_states = vec![ @@ -555,7 +560,8 @@ impl MockContext { impl Ics26Context for MockContext {} -impl Ics20Context for MockContext {} +impl Ics20Context for MockContext { +} impl CapabilityReader for MockContext { fn get_capability(&self, _name: &CapabilityName) -> Result { diff --git a/relayer/src/foreign_client.rs b/relayer/src/foreign_client.rs index 90e32da77..a4260ecfc 100644 --- a/relayer/src/foreign_client.rs +++ b/relayer/src/foreign_client.rs @@ -919,7 +919,9 @@ impl ForeignClient AnyClientState::Mock(client_state), + + + AnyClientState::Mock(client_state) => AnyClientState::Mock(client_state), AnyClientState::Tendermint(client_state) => AnyClientState::Tendermint(client_state), AnyClientState::Grandpa(client_state) => { let mut mmr_root_height = client_state.latest_commitment.block_number;