@@ -845,12 +845,12 @@ impl ChannelReader for MockContext {
845
845
sha2:: Sha256 :: digest ( value) . to_vec ( )
846
846
}
847
847
848
- fn host_height ( & self ) -> Height {
849
- self . latest_height ( )
848
+ fn host_height ( & self ) -> Result < Height , Ics04Error > {
849
+ Ok ( self . latest_height ( ) )
850
850
}
851
851
852
- fn host_timestamp ( & self ) -> Timestamp {
853
- ClientReader :: host_timestamp ( self )
852
+ fn host_timestamp ( & self ) -> Result < Timestamp , Ics04Error > {
853
+ ClientReader :: host_timestamp ( self ) . map_err ( |e| Ics04Error :: other ( e . to_string ( ) ) )
854
854
}
855
855
856
856
fn host_consensus_state ( & self , height : Height ) -> Result < Box < dyn ConsensusState > , Ics04Error > {
@@ -1103,13 +1103,13 @@ impl ConnectionReader for MockContext {
1103
1103
ClientReader :: decode_client_state ( self , client_state) . map_err ( Ics03Error :: ics02_client)
1104
1104
}
1105
1105
1106
- fn host_current_height ( & self ) -> Height {
1107
- self . latest_height ( )
1106
+ fn host_current_height ( & self ) -> Result < Height , Ics03Error > {
1107
+ Ok ( self . latest_height ( ) )
1108
1108
}
1109
1109
1110
- fn host_oldest_height ( & self ) -> Height {
1110
+ fn host_oldest_height ( & self ) -> Result < Height , Ics03Error > {
1111
1111
// history must be non-empty, so `self.history[0]` is valid
1112
- self . history [ 0 ] . height ( )
1112
+ Ok ( self . history [ 0 ] . height ( ) )
1113
1113
}
1114
1114
1115
1115
fn commitment_prefix ( & self ) -> CommitmentPrefix {
@@ -1275,17 +1275,18 @@ impl ClientReader for MockContext {
1275
1275
Ok ( None )
1276
1276
}
1277
1277
1278
- fn host_height ( & self ) -> Height {
1279
- self . latest_height ( )
1278
+ fn host_height ( & self ) -> Result < Height , Ics02Error > {
1279
+ Ok ( self . latest_height ( ) )
1280
1280
}
1281
1281
1282
- fn host_timestamp ( & self ) -> Timestamp {
1283
- self . history
1282
+ fn host_timestamp ( & self ) -> Result < Timestamp , Ics02Error > {
1283
+ Ok ( self
1284
+ . history
1284
1285
. last ( )
1285
1286
. expect ( "history cannot be empty" )
1286
1287
. timestamp ( )
1287
1288
. add ( self . block_time )
1288
- . unwrap ( )
1289
+ . unwrap ( ) )
1289
1290
}
1290
1291
1291
1292
fn host_consensus_state ( & self , height : Height ) -> Result < Box < dyn ConsensusState > , Ics02Error > {
@@ -1401,8 +1402,8 @@ impl ClientKeeper for MockContext {
1401
1402
}
1402
1403
1403
1404
impl RelayerContext for MockContext {
1404
- fn query_latest_height ( & self ) -> Height {
1405
- self . host_current_height ( )
1405
+ fn query_latest_height ( & self ) -> Result < Height , Ics18Error > {
1406
+ self . host_current_height ( ) . map_err ( Ics18Error :: ics03 )
1406
1407
}
1407
1408
1408
1409
fn query_client_full_state ( & self , client_id : & ClientId ) -> Option < Box < dyn ClientState > > {
@@ -1411,7 +1412,7 @@ impl RelayerContext for MockContext {
1411
1412
}
1412
1413
1413
1414
fn query_latest_header ( & self ) -> Option < Box < dyn Header > > {
1414
- let block_ref = self . host_block ( self . host_current_height ( ) ) ;
1415
+ let block_ref = self . host_block ( self . host_current_height ( ) . unwrap ( ) ) ;
1415
1416
block_ref. cloned ( ) . map ( Header :: into_box)
1416
1417
}
1417
1418
0 commit comments