1
+ use core:: fmt:: Debug ;
2
+
3
+ use basecoin_store:: context:: ProvableStore ;
1
4
use ibc:: core:: channel:: types:: packet:: Packet ;
2
5
use ibc:: core:: client:: context:: client_state:: ClientStateValidation ;
3
6
use ibc:: core:: host:: types:: identifiers:: { ChannelId , ClientId , ConnectionId , PortId } ;
4
7
use ibc:: core:: host:: types:: path:: ChannelEndPath ;
5
8
use ibc:: core:: host:: ValidationContext ;
6
9
use ibc:: primitives:: Signer ;
7
10
8
- use crate :: context:: TestContext ;
11
+ use crate :: context:: StoreGenericTestContext ;
9
12
use crate :: hosts:: { HostClientState , HostConsensusState , TestHost } ;
10
13
use crate :: relayer:: utils:: TypedRelayerOps ;
11
14
use crate :: testapp:: ibc:: clients:: { AnyClientState , AnyConsensusState } ;
12
- use crate :: testapp:: ibc:: core:: types:: DefaultIbcStore ;
15
+ use crate :: testapp:: ibc:: core:: types:: MockIbcStore ;
13
16
14
17
/// A relayer context that allows interaction between two [`TestContext`] instances.
15
- pub struct RelayerContext < A , B >
18
+ pub struct RelayerContext < A , B , S >
16
19
where
17
20
A : TestHost ,
18
21
B : TestHost ,
22
+ S : ProvableStore + Debug ,
19
23
AnyClientState : From < HostClientState < A > > ,
20
24
AnyConsensusState : From < HostConsensusState < A > > ,
21
25
AnyClientState : From < HostClientState < B > > ,
22
26
AnyConsensusState : From < HostConsensusState < B > > ,
23
- HostClientState < A > : ClientStateValidation < DefaultIbcStore > ,
24
- HostClientState < B > : ClientStateValidation < DefaultIbcStore > ,
27
+ HostClientState < A > : ClientStateValidation < MockIbcStore < S , AnyClientState , AnyConsensusState > > ,
28
+ HostClientState < B > : ClientStateValidation < MockIbcStore < S , AnyClientState , AnyConsensusState > > ,
25
29
{
26
- ctx_a : TestContext < A > ,
27
- ctx_b : TestContext < B > ,
30
+ ctx_a : StoreGenericTestContext < S , A > ,
31
+ ctx_b : StoreGenericTestContext < S , B > ,
28
32
}
29
33
30
- impl < A , B > RelayerContext < A , B >
34
+ impl < A , B , S > RelayerContext < A , B , S >
31
35
where
32
36
A : TestHost ,
33
37
B : TestHost ,
38
+ S : ProvableStore + Debug ,
34
39
AnyClientState : From < HostClientState < A > > ,
35
40
AnyConsensusState : From < HostConsensusState < A > > ,
36
41
AnyClientState : From < HostClientState < B > > ,
37
42
AnyConsensusState : From < HostConsensusState < B > > ,
38
- HostClientState < A > : ClientStateValidation < DefaultIbcStore > ,
39
- HostClientState < B > : ClientStateValidation < DefaultIbcStore > ,
43
+ HostClientState < A > : ClientStateValidation < MockIbcStore < S , AnyClientState , AnyConsensusState > > ,
44
+ HostClientState < B > : ClientStateValidation < MockIbcStore < S , AnyClientState , AnyConsensusState > > ,
40
45
{
41
46
/// Creates a new relayer context with the given [`TestContext`] instances.
42
- pub fn new ( ctx_a : TestContext < A > , ctx_b : TestContext < B > ) -> Self {
47
+ pub fn new ( ctx_a : StoreGenericTestContext < S , A > , ctx_b : StoreGenericTestContext < S , B > ) -> Self {
43
48
Self { ctx_a, ctx_b }
44
49
}
45
50
46
51
/// Returns an immutable reference to the first context.
47
- pub fn get_ctx_a ( & self ) -> & TestContext < A > {
52
+ pub fn get_ctx_a ( & self ) -> & StoreGenericTestContext < S , A > {
48
53
& self . ctx_a
49
54
}
50
55
51
56
/// Returns an immutable reference to the second context.
52
- pub fn get_ctx_b ( & self ) -> & TestContext < B > {
57
+ pub fn get_ctx_b ( & self ) -> & StoreGenericTestContext < S , B > {
53
58
& self . ctx_b
54
59
}
55
60
56
61
/// Returns a mutable reference to the first context.
57
- pub fn get_ctx_a_mut ( & mut self ) -> & mut TestContext < A > {
62
+ pub fn get_ctx_a_mut ( & mut self ) -> & mut StoreGenericTestContext < S , A > {
58
63
& mut self . ctx_a
59
64
}
60
65
61
66
/// Returns a mutable reference to the second context.
62
- pub fn get_ctx_b_mut ( & mut self ) -> & mut TestContext < B > {
67
+ pub fn get_ctx_b_mut ( & mut self ) -> & mut StoreGenericTestContext < S , B > {
63
68
& mut self . ctx_b
64
69
}
65
70
66
71
/// Creates a light client of second context on the first context.
67
72
/// Returns the client identifier of the created client.
68
73
pub fn create_client_on_a ( & mut self , signer : Signer ) -> ClientId {
69
- TypedRelayerOps :: < A , B > :: create_client_on_a ( & mut self . ctx_a , & self . ctx_b , signer)
74
+ TypedRelayerOps :: < A , B , S > :: create_client_on_a ( & mut self . ctx_a , & self . ctx_b , signer)
70
75
}
71
76
72
77
/// Creates a light client of first context on the second context.
73
78
/// Returns the client identifier of the created client.
74
79
pub fn create_client_on_b ( & mut self , signer : Signer ) -> ClientId {
75
- TypedRelayerOps :: < B , A > :: create_client_on_a ( & mut self . ctx_b , & self . ctx_a , signer)
80
+ TypedRelayerOps :: < B , A , S > :: create_client_on_a ( & mut self . ctx_b , & self . ctx_a , signer)
76
81
}
77
82
78
83
/// Updates the client on the first context with the latest header of the second context.
79
84
pub fn update_client_on_a_with_sync ( & mut self , client_id_on_a : ClientId , signer : Signer ) {
80
- TypedRelayerOps :: < A , B > :: update_client_on_a_with_sync (
85
+ TypedRelayerOps :: < A , B , S > :: update_client_on_a_with_sync (
81
86
& mut self . ctx_a ,
82
87
& mut self . ctx_b ,
83
88
client_id_on_a,
87
92
88
93
/// Updates the client on the second context with the latest header of the first context.
89
94
pub fn update_client_on_b_with_sync ( & mut self , client_id_on_b : ClientId , signer : Signer ) {
90
- TypedRelayerOps :: < B , A > :: update_client_on_a_with_sync (
95
+ TypedRelayerOps :: < B , A , S > :: update_client_on_a_with_sync (
91
96
& mut self . ctx_b ,
92
97
& mut self . ctx_a ,
93
98
client_id_on_b,
@@ -103,7 +108,7 @@ where
103
108
client_id_on_b : ClientId ,
104
109
signer : Signer ,
105
110
) -> ( ConnectionId , ConnectionId ) {
106
- TypedRelayerOps :: < A , B > :: create_connection_on_a (
111
+ TypedRelayerOps :: < A , B , S > :: create_connection_on_a (
107
112
& mut self . ctx_a ,
108
113
& mut self . ctx_b ,
109
114
client_id_on_a,
@@ -120,7 +125,7 @@ where
120
125
client_id_on_a : ClientId ,
121
126
signer : Signer ,
122
127
) -> ( ConnectionId , ConnectionId ) {
123
- TypedRelayerOps :: < B , A > :: create_connection_on_a (
128
+ TypedRelayerOps :: < B , A , S > :: create_connection_on_a (
124
129
& mut self . ctx_b ,
125
130
& mut self . ctx_a ,
126
131
client_id_on_b,
@@ -155,7 +160,7 @@ where
155
160
. client_id ( )
156
161
. clone ( ) ;
157
162
158
- TypedRelayerOps :: < A , B > :: create_channel_on_a (
163
+ TypedRelayerOps :: < A , B , S > :: create_channel_on_a (
159
164
& mut self . ctx_a ,
160
165
& mut self . ctx_b ,
161
166
client_id_on_a,
@@ -194,7 +199,7 @@ where
194
199
. client_id ( )
195
200
. clone ( ) ;
196
201
197
- TypedRelayerOps :: < B , A > :: create_channel_on_a (
202
+ TypedRelayerOps :: < B , A , S > :: create_channel_on_a (
198
203
& mut self . ctx_b ,
199
204
& mut self . ctx_a ,
200
205
client_id_on_b,
@@ -248,7 +253,7 @@ where
248
253
. client_id ( )
249
254
. clone ( ) ;
250
255
251
- TypedRelayerOps :: < A , B > :: close_channel_on_a (
256
+ TypedRelayerOps :: < A , B , S > :: close_channel_on_a (
252
257
& mut self . ctx_a ,
253
258
& mut self . ctx_b ,
254
259
client_id_on_a,
@@ -302,7 +307,7 @@ where
302
307
. client_id ( )
303
308
. clone ( ) ;
304
309
305
- TypedRelayerOps :: < B , A > :: close_channel_on_a (
310
+ TypedRelayerOps :: < B , A , S > :: close_channel_on_a (
306
311
& mut self . ctx_b ,
307
312
& mut self . ctx_a ,
308
313
client_id_on_b,
@@ -358,7 +363,7 @@ where
358
363
. client_id ( )
359
364
. clone ( ) ;
360
365
361
- TypedRelayerOps :: < A , B > :: submit_packet_on_b (
366
+ TypedRelayerOps :: < A , B , S > :: submit_packet_on_b (
362
367
& mut self . ctx_a ,
363
368
& mut self . ctx_b ,
364
369
packet,
@@ -411,7 +416,7 @@ where
411
416
. client_id ( )
412
417
. clone ( ) ;
413
418
414
- TypedRelayerOps :: < A , B > :: timeout_packet_from_a (
419
+ TypedRelayerOps :: < A , B , S > :: timeout_packet_from_a (
415
420
& mut self . ctx_a ,
416
421
& mut self . ctx_b ,
417
422
packet,
@@ -464,7 +469,7 @@ where
464
469
. client_id ( )
465
470
. clone ( ) ;
466
471
467
- TypedRelayerOps :: < A , B > :: timeout_packet_from_a_on_channel_close (
472
+ TypedRelayerOps :: < A , B , S > :: timeout_packet_from_a_on_channel_close (
468
473
& mut self . ctx_a ,
469
474
& mut self . ctx_b ,
470
475
packet,
0 commit comments