@@ -231,7 +231,7 @@ pub struct MockContextConfig {
231
231
block_time : Duration ,
232
232
233
233
#[ builder( default = 5 ) ]
234
- max_history_size : usize ,
234
+ max_history_size : u64 ,
235
235
236
236
latest_height : Height ,
237
237
@@ -254,7 +254,7 @@ impl From<MockContextConfig> for MockContext {
254
254
255
255
// Compute the number of blocks to store.
256
256
let n = min (
257
- params. max_history_size as u64 ,
257
+ params. max_history_size ,
258
258
params. latest_height . revision_height ( ) ,
259
259
) ;
260
260
@@ -420,7 +420,7 @@ impl MockContext {
420
420
validator_history : & [ Vec < TestgenValidator > ] ,
421
421
latest_height : Height ,
422
422
) -> Self {
423
- let max_history_size = validator_history. len ( ) - 1 ;
423
+ let max_history_size = validator_history. len ( ) as u64 - 1 ;
424
424
425
425
assert_ne ! (
426
426
max_history_size, 0 ,
@@ -434,7 +434,7 @@ impl MockContext {
434
434
) ;
435
435
436
436
assert ! (
437
- max_history_size as u64 <= latest_height. revision_height( ) ,
437
+ max_history_size <= latest_height. revision_height( ) ,
438
438
"The number of blocks must be greater than the number of validator set histories"
439
439
) ;
440
440
@@ -455,25 +455,20 @@ impl MockContext {
455
455
HostBlock :: generate_block_with_validators (
456
456
host_id. clone ( ) ,
457
457
host_type,
458
- latest_height
459
- . sub ( i as u64 )
460
- . expect ( "Never fails" )
461
- . revision_height ( ) ,
458
+ latest_height. sub ( i) . expect ( "Never fails" ) . revision_height ( ) ,
462
459
next_block_timestamp
463
- . sub ( Duration :: from_secs (
464
- DEFAULT_BLOCK_TIME_SECS * ( i as u64 + 1 ) ,
465
- ) )
460
+ . sub ( Duration :: from_secs ( DEFAULT_BLOCK_TIME_SECS * ( i + 1 ) ) )
466
461
. expect ( "Never fails" ) ,
467
- & validator_history[ max_history_size - 1 - i ] ,
468
- & validator_history[ max_history_size - i] ,
462
+ & validator_history[ ( max_history_size - i ) as usize - 1 ] ,
463
+ & validator_history[ ( max_history_size - i) as usize ] ,
469
464
)
470
465
} )
471
466
. collect ( ) ;
472
467
473
468
MockContext {
474
469
host_chain_type : host_type,
475
470
host_chain_id : host_id. clone ( ) ,
476
- max_history_size : max_history_size as u64 ,
471
+ max_history_size,
477
472
history,
478
473
block_time,
479
474
ibc_store : Arc :: new ( Mutex :: new ( MockIbcStore :: default ( ) ) ) ,
0 commit comments