File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1899,7 +1899,9 @@ impl<'a> ChainStoreUpdate<'a> {
18991899
19001900 pub fn update_tail ( & mut self , height : BlockHeight ) {
19011901 self . tail = Some ( height) ;
1902- if self . chunk_tail . is_none ( ) {
1902+ let genesis_height = self . get_genesis_height ( ) ;
1903+ let chunk_tail = self . chunk_tail ( ) . unwrap_or_else ( |_| genesis_height) ;
1904+ if chunk_tail == genesis_height {
19031905 // For consistency, Chunk Tail should be set if Tail is set
19041906 self . chunk_tail = Some ( self . get_genesis_height ( ) ) ;
19051907 }
Original file line number Diff line number Diff line change @@ -875,6 +875,21 @@ fn test_gc_block_skips() {
875875 }
876876}
877877
878+ #[ test]
879+ fn test_gc_chunk_tail ( ) {
880+ let mut chain_genesis = ChainGenesis :: test ( ) ;
881+ let epoch_length = 100 ;
882+ chain_genesis. epoch_length = epoch_length;
883+ let mut env = TestEnv :: new ( chain_genesis. clone ( ) , 1 , 1 ) ;
884+ let mut chunk_tail = 0 ;
885+ for i in ( 1 ..10 ) . chain ( 101 ..epoch_length * 6 ) {
886+ env. produce_block ( 0 , i) ;
887+ let cur_chunk_tail = env. clients [ 0 ] . chain . store ( ) . chunk_tail ( ) . unwrap ( ) ;
888+ assert ! ( cur_chunk_tail >= chunk_tail) ;
889+ chunk_tail = cur_chunk_tail;
890+ }
891+ }
892+
878893#[ test]
879894fn test_gc_execution_outcome ( ) {
880895 let epoch_length = 5 ;
You can’t perform that action at this time.
0 commit comments