@@ -9,6 +9,7 @@ use basecoin_store::types::{BinStore, JsonStore, ProtobufStore, TypedSet, TypedS
99use ibc:: core:: channel:: types:: channel:: ChannelEnd ;
1010use ibc:: core:: channel:: types:: commitment:: { AcknowledgementCommitment , PacketCommitment } ;
1111use ibc:: core:: client:: context:: client_state:: ClientStateValidation ;
12+ use ibc:: core:: client:: context:: consensus_state:: ConsensusState ;
1213use ibc:: core:: client:: types:: Height ;
1314use ibc:: core:: connection:: types:: ConnectionEnd ;
1415use ibc:: core:: handler:: types:: events:: IbcEvent ;
@@ -32,17 +33,18 @@ use typed_builder::TypedBuilder;
3233use crate :: context:: { MockStore , TestContext } ;
3334use crate :: fixtures:: core:: context:: TestContextConfig ;
3435use crate :: hosts:: { HostClientState , HostConsensusState , TestBlock , TestHeader , TestHost } ;
35- use crate :: testapp:: ibc:: clients:: mock:: header:: MockHeader ;
3636use crate :: testapp:: ibc:: clients:: { AnyClientState , AnyConsensusState } ;
3737pub const DEFAULT_BLOCK_TIME_SECS : u64 = 3 ;
3838
39- pub type DefaultIbcStore = MockIbcStore < MockStore > ;
39+ pub type DefaultIbcStore = MockIbcStore < MockStore , AnyClientState , AnyConsensusState > ;
4040
4141/// An object that stores all IBC related data.
4242#[ derive( Debug ) ]
43- pub struct MockIbcStore < S >
43+ pub struct MockIbcStore < S , ACL , ACS >
4444where
4545 S : ProvableStore + Debug ,
46+ ACL : ClientStateValidation < Self > + Clone ,
47+ ACS : ConsensusState + Clone ,
4648{
4749 /// chain revision number,
4850 pub revision_number : Arc < Mutex < u64 > > ,
6264 pub client_processed_heights :
6365 ProtobufStore < SharedStore < S > , ClientUpdateHeightPath , Height , RawHeight > ,
6466 /// A typed-store for AnyClientState
65- pub client_state_store : ProtobufStore < SharedStore < S > , ClientStatePath , AnyClientState , Any > ,
67+ pub client_state_store : ProtobufStore < SharedStore < S > , ClientStatePath , ACL , Any > ,
6668 /// A typed-store for AnyConsensusState
67- pub consensus_state_store :
68- ProtobufStore < SharedStore < S > , ClientConsensusStatePath , AnyConsensusState , Any > ,
69+ pub consensus_state_store : ProtobufStore < SharedStore < S > , ClientConsensusStatePath , ACS , Any > ,
6970 /// A typed-store for ConnectionEnd
7071 pub connection_end_store :
7172 ProtobufStore < SharedStore < S > , ConnectionPath , ConnectionEnd , RawConnectionEnd > ,
8687 /// A typed-store for packet ack
8788 pub packet_ack_store : BinStore < SharedStore < S > , AckPath , AcknowledgementCommitment > ,
8889 /// Map of host consensus states
89- pub host_consensus_states : Arc < Mutex < BTreeMap < u64 , AnyConsensusState > > > ,
90+ pub host_consensus_states : Arc < Mutex < BTreeMap < u64 , ACS > > > ,
9091 /// Map of older ibc commitment proofs
9192 pub ibc_commiment_proofs : Arc < Mutex < BTreeMap < u64 , CommitmentProof > > > ,
9293 /// IBC Events
9596 pub logs : Arc < Mutex < Vec < String > > > ,
9697}
9798
98- impl < S > MockIbcStore < S >
99+ impl < S , ACL , ACS > MockIbcStore < S , ACL , ACS >
99100where
100101 S : ProvableStore + Debug ,
102+ ACL : ClientStateValidation < Self > + Clone ,
103+ ACS : ConsensusState + Clone ,
101104{
102105 pub fn new ( revision_number : u64 , store : S ) -> Self {
103106 let shared_store = SharedStore :: new ( store) ;
@@ -144,7 +147,7 @@ where
144147 }
145148 }
146149
147- fn store_host_consensus_state ( & mut self , height : u64 , consensus_state : AnyConsensusState ) {
150+ fn store_host_consensus_state ( & mut self , height : u64 , consensus_state : ACS ) {
148151 self . host_consensus_states
149152 . lock ( )
150153 . insert ( height, consensus_state) ;
@@ -154,12 +157,7 @@ where
154157 self . ibc_commiment_proofs . lock ( ) . insert ( height, proof) ;
155158 }
156159
157- pub fn begin_block (
158- & mut self ,
159- height : u64 ,
160- consensus_state : AnyConsensusState ,
161- proof : CommitmentProof ,
162- ) {
160+ pub fn begin_block ( & mut self , height : u64 , consensus_state : ACS , proof : CommitmentProof ) {
163161 assert_eq ! ( self . store. current_height( ) , height) ;
164162 self . store_host_consensus_state ( height, consensus_state) ;
165163 self . store_ibc_commitment_proof ( height, proof) ;
@@ -178,18 +176,20 @@ where
178176 }
179177}
180178
181- impl < S > Default for MockIbcStore < S >
179+ impl < S , ACL , ACS > Default for MockIbcStore < S , ACL , ACS >
182180where
183181 S : ProvableStore + Debug + Default ,
182+ ACL : ClientStateValidation < Self > + Clone ,
183+ ACS : ConsensusState + Clone ,
184184{
185185 fn default ( ) -> Self {
186- // Note: this creates a MockIbcStore which has MockConsensusState as Host ConsensusState
187186 let mut ibc_store = Self :: new ( 0 , S :: default ( ) ) ;
188187 ibc_store. store . commit ( ) . expect ( "no error" ) ;
189- ibc_store. store_host_consensus_state (
190- ibc_store. store . current_height ( ) ,
191- MockHeader :: default ( ) . into_consensus_state ( ) . into ( ) ,
192- ) ;
188+ // // FIXME(rano): store a consensus state.
189+ // ibc_store.store_host_consensus_state(
190+ // ibc_store.store.current_height(),
191+ // MockHeader::default().into_consensus_state().into(),
192+ // );
193193 ibc_store. store_ibc_commitment_proof (
194194 ibc_store. store . current_height ( ) ,
195195 CommitmentProof :: default ( ) ,
0 commit comments