@@ -33,6 +33,7 @@ use super::client_ctx::{MockClientRecord, PortChannelIdMap};
33
33
use crate :: fixtures:: clients:: tendermint:: {
34
34
dummy_tm_client_state_from_header, ClientStateConfig as TmClientStateConfig ,
35
35
} ;
36
+ use crate :: fixtures:: core:: context:: MockContextConfig ;
36
37
use crate :: hosts:: block:: { HostBlock , HostType } ;
37
38
use crate :: relayer:: error:: RelayerError ;
38
39
use crate :: testapp:: ibc:: clients:: mock:: client_state:: {
@@ -147,12 +148,7 @@ pub struct MockClientConfig {
147
148
/// creation of new domain objects.
148
149
impl Default for MockContext {
149
150
fn default ( ) -> Self {
150
- Self :: new (
151
- ChainId :: new ( "mockgaia-0" ) . expect ( "Never fails" ) ,
152
- HostType :: Mock ,
153
- 5 ,
154
- Height :: new ( 0 , 5 ) . expect ( "Never fails" ) ,
155
- )
151
+ MockContextConfig :: builder ( ) . build ( )
156
152
}
157
153
}
158
154
@@ -183,6 +179,10 @@ impl MockContext {
183
179
/// the chain maintain in its history, which also determines the pruning window. Parameter
184
180
/// `latest_height` determines the current height of the chain. This context
185
181
/// has support to emulate two type of underlying chains: Mock or SyntheticTendermint.
182
+ #[ deprecated(
183
+ since = "0.49.2" ,
184
+ note = "Please use `MockContextConfig::builder().build()` instead"
185
+ ) ]
186
186
pub fn new (
187
187
host_id : ChainId ,
188
188
host_type : HostType ,
@@ -239,6 +239,10 @@ impl MockContext {
239
239
/// Note: the validator history is used accordingly for current validator set and next validator set.
240
240
/// `validator_history[i]` and `validator_history[i+1]` is i'th block's current and next validator set.
241
241
/// The number of blocks will be `validator_history.len() - 1` due to the above.
242
+ #[ deprecated(
243
+ since = "0.49.2" ,
244
+ note = "Please use `MockContextConfig::builder().build()` instead"
245
+ ) ]
242
246
pub fn new_with_validator_history (
243
247
host_id : ChainId ,
244
248
host_type : HostType ,
@@ -816,93 +820,88 @@ mod tests {
816
820
let tests: Vec < Test > = vec ! [
817
821
Test {
818
822
name: "Empty history, small pruning window" . to_string( ) ,
819
- ctx: MockContext :: new(
820
- mock_chain_id. clone( ) ,
821
- HostType :: Mock ,
822
- 2 ,
823
- Height :: new( cv, 1 ) . expect( "Never fails" ) ,
824
- ) ,
823
+ ctx: MockContextConfig :: builder( )
824
+ . host_id( mock_chain_id. clone( ) )
825
+ . max_history_size( 2 )
826
+ . latest_height( Height :: new( cv, 1 ) . expect( "Never fails" ) )
827
+ . build( ) ,
825
828
} ,
826
829
Test {
827
830
name: "[Synthetic TM host] Empty history, small pruning window" . to_string( ) ,
828
- ctx: MockContext :: new (
829
- mock_chain_id. clone( ) ,
830
- HostType :: SyntheticTendermint ,
831
- 2 ,
832
- Height :: new( cv, 1 ) . expect( "Never fails" ) ,
833
- ) ,
831
+ ctx: MockContextConfig :: builder ( )
832
+ . host_id ( mock_chain_id. clone( ) )
833
+ . host_type ( HostType :: SyntheticTendermint )
834
+ . max_history_size ( 2 )
835
+ . latest_height ( Height :: new( cv, 1 ) . expect( "Never fails" ) )
836
+ . build ( ) ,
834
837
} ,
835
838
Test {
836
839
name: "Large pruning window" . to_string( ) ,
837
- ctx: MockContext :: new(
838
- mock_chain_id. clone( ) ,
839
- HostType :: Mock ,
840
- 30 ,
841
- Height :: new( cv, 2 ) . expect( "Never fails" ) ,
842
- ) ,
840
+ ctx: MockContextConfig :: builder( )
841
+ . host_id( mock_chain_id. clone( ) )
842
+ . max_history_size( 30 )
843
+ . latest_height( Height :: new( cv, 2 ) . expect( "Never fails" ) )
844
+ . build( ) ,
843
845
} ,
844
846
Test {
845
847
name: "[Synthetic TM host] Large pruning window" . to_string( ) ,
846
- ctx: MockContext :: new (
847
- mock_chain_id. clone( ) ,
848
- HostType :: SyntheticTendermint ,
849
- 30 ,
850
- Height :: new( cv, 2 ) . expect( "Never fails" ) ,
851
- ) ,
848
+ ctx: MockContextConfig :: builder ( )
849
+ . host_id ( mock_chain_id. clone( ) )
850
+ . host_type ( HostType :: SyntheticTendermint )
851
+ . max_history_size ( 30 )
852
+ . latest_height ( Height :: new( cv, 2 ) . expect( "Never fails" ) )
853
+ . build ( ) ,
852
854
} ,
853
855
Test {
854
856
name: "Small pruning window" . to_string( ) ,
855
- ctx: MockContext :: new(
856
- mock_chain_id. clone( ) ,
857
- HostType :: Mock ,
858
- 3 ,
859
- Height :: new( cv, 30 ) . expect( "Never fails" ) ,
860
- ) ,
857
+ ctx: MockContextConfig :: builder( )
858
+ . host_id( mock_chain_id. clone( ) )
859
+ . max_history_size( 3 )
860
+ . latest_height( Height :: new( cv, 30 ) . expect( "Never fails" ) )
861
+ . build( ) ,
861
862
} ,
862
863
Test {
863
864
name: "[Synthetic TM host] Small pruning window" . to_string( ) ,
864
- ctx: MockContext :: new (
865
- mock_chain_id. clone( ) ,
866
- HostType :: SyntheticTendermint ,
867
- 3 ,
868
- Height :: new( cv, 30 ) . expect( "Never fails" ) ,
869
- ) ,
865
+ ctx: MockContextConfig :: builder ( )
866
+ . host_id ( mock_chain_id. clone( ) )
867
+ . host_type ( HostType :: SyntheticTendermint )
868
+ . max_history_size ( 3 )
869
+ . latest_height ( Height :: new( cv, 30 ) . expect( "Never fails" ) )
870
+ . build ( ) ,
870
871
} ,
871
872
Test {
872
873
name: "Small pruning window, small starting height" . to_string( ) ,
873
- ctx: MockContext :: new(
874
- mock_chain_id. clone( ) ,
875
- HostType :: Mock ,
876
- 3 ,
877
- Height :: new( cv, 2 ) . expect( "Never fails" ) ,
878
- ) ,
874
+ ctx: MockContextConfig :: builder( )
875
+ . host_id( mock_chain_id. clone( ) )
876
+ . max_history_size( 3 )
877
+ . latest_height( Height :: new( cv, 2 ) . expect( "Never fails" ) )
878
+ . build( ) ,
879
879
} ,
880
880
Test {
881
881
name: "[Synthetic TM host] Small pruning window, small starting height" . to_string( ) ,
882
- ctx: MockContext :: new (
883
- mock_chain_id. clone( ) ,
884
- HostType :: SyntheticTendermint ,
885
- 3 ,
886
- Height :: new( cv, 2 ) . expect( "Never fails" ) ,
887
- ) ,
882
+ ctx: MockContextConfig :: builder ( )
883
+ . host_id ( mock_chain_id. clone( ) )
884
+ . host_type ( HostType :: SyntheticTendermint )
885
+ . max_history_size ( 3 )
886
+ . latest_height ( Height :: new( cv, 2 ) . expect( "Never fails" ) )
887
+ . build ( ) ,
888
888
} ,
889
889
Test {
890
890
name: "Large pruning window, large starting height" . to_string( ) ,
891
- ctx: MockContext :: new(
892
- mock_chain_id. clone( ) ,
893
- HostType :: Mock ,
894
- 50 ,
895
- Height :: new( cv, 2000 ) . expect( "Never fails" ) ,
896
- ) ,
891
+ ctx: MockContextConfig :: builder( )
892
+ . host_id( mock_chain_id. clone( ) )
893
+ . max_history_size( 50 )
894
+ . latest_height( Height :: new( cv, 2000 ) . expect( "Never fails" ) )
895
+ . build( ) ,
897
896
} ,
898
897
Test {
899
898
name: "[Synthetic TM host] Large pruning window, large starting height" . to_string( ) ,
900
- ctx: MockContext :: new (
901
- mock_chain_id,
902
- HostType :: SyntheticTendermint ,
903
- 50 ,
904
- Height :: new( cv, 2000 ) . expect( "Never fails" ) ,
905
- ) ,
899
+ ctx: MockContextConfig :: builder ( )
900
+ . host_id ( mock_chain_id)
901
+ . host_type ( HostType :: SyntheticTendermint )
902
+ . max_history_size ( 50 )
903
+ . latest_height ( Height :: new( cv, 2000 ) . expect( "Never fails" ) )
904
+ . build ( ) ,
906
905
} ,
907
906
] ;
908
907
0 commit comments