@@ -466,7 +466,7 @@ where
466
466
let log_id = store. first_known_log_id ( ) . await ?;
467
467
assert_eq ! ( LogId :: new( 0 , 0 ) , log_id, "store initialized with a log at 0" ) ;
468
468
469
- tracing:: info!( "--- only logs " ) ;
469
+ tracing:: info!( "--- returns the min id " ) ;
470
470
{
471
471
store
472
472
. append_to_log ( & [
@@ -485,26 +485,34 @@ where
485
485
486
486
// NOTE: it assumes non applied logs always exist.
487
487
let log_id = store. first_known_log_id ( ) . await ?;
488
- assert_eq ! ( LogId :: new( 1 , 2 ) , log_id) ;
489
- }
488
+ assert_eq ! ( LogId :: new( 0 , 0 ) , log_id, "last_applied is 0-0" ) ;
490
489
491
- tracing:: info!( "--- return applied_log_id only when there is no log at all" ) ;
492
- {
493
490
store
494
491
. apply_to_state_machine ( & [ & Entry {
495
492
log_id : LogId { term : 1 , index : 1 } ,
496
493
payload : EntryPayload :: Blank ,
497
494
} ] )
498
495
. await ?;
496
+ let log_id = store. first_known_log_id ( ) . await ?;
497
+ assert_eq ! ( LogId :: new( 1 , 1 ) , log_id) ;
499
498
500
- // NOTE: it assumes non applied logs always exist.
499
+ store
500
+ . apply_to_state_machine ( & [ & Entry {
501
+ log_id : LogId { term : 1 , index : 2 } ,
502
+ payload : EntryPayload :: Blank ,
503
+ } ] )
504
+ . await ?;
501
505
let log_id = store. first_known_log_id ( ) . await ?;
502
- assert_eq ! ( LogId { term : 1 , index : 2 } , log_id) ;
506
+ assert_eq ! ( LogId :: new ( 1 , 2 ) , log_id) ;
503
507
504
- // When there is no logs, return applied_log_id
505
- store. delete_logs_from ( 0 ..3 ) . await ?;
508
+ store
509
+ . apply_to_state_machine ( & [ & Entry {
510
+ log_id : LogId { term : 1 , index : 3 } ,
511
+ payload : EntryPayload :: Blank ,
512
+ } ] )
513
+ . await ?;
506
514
let log_id = store. first_known_log_id ( ) . await ?;
507
- assert_eq ! ( LogId { term : 1 , index : 1 } , log_id) ;
515
+ assert_eq ! ( LogId :: new ( 1 , 2 ) , log_id, "least id is in log" ) ;
508
516
}
509
517
510
518
Ok ( ( ) )
0 commit comments