@@ -25,14 +25,23 @@ type Subchain = {
2525}
2626
2727const common = new Common ( { chain : Mainnet } )
28- const block49 = createBlock ( { header : { number : 49 } } , { common } )
29- const block49B = createBlock ( { header : { number : 49 , extraData : utf8ToBytes ( 'B' ) } } , { common } )
30- const block50 = createBlock ( { header : { number : 50 , parentHash : block49 . hash ( ) } } , { common } )
28+ const block49 = createBlock ( { header : { number : 49 } } , { common, setHardfork : true } )
29+ const block49B = createBlock (
30+ { header : { number : 49 , extraData : utf8ToBytes ( 'B' ) } } ,
31+ { common, setHardfork : true } ,
32+ )
33+ const block50 = createBlock (
34+ { header : { number : 50 , parentHash : block49 . hash ( ) } } ,
35+ { common, setHardfork : true } ,
36+ )
3137const block50B = createBlock (
3238 { header : { number : 50 , parentHash : block49 . hash ( ) , gasLimit : 999 } } ,
33- { common } ,
39+ { common, setHardfork : true } ,
40+ )
41+ const block51 = createBlock (
42+ { header : { number : 51 , parentHash : block50 . hash ( ) } } ,
43+ { common, setHardfork : true } ,
3444)
35- const block51 = createBlock ( { header : { number : 51 , parentHash : block50 . hash ( ) } } , { common } )
3645
3746describe ( '[Skeleton]/ startup scenarios ' , ( ) => {
3847 it ( 'starts the chain when starting the skeleton' , async ( ) => {
@@ -594,20 +603,20 @@ describe('[Skeleton] / setHead', async () => {
594603 'canonical height should change when setHead is set with force=true' ,
595604 )
596605
597- // unlink the skeleton for the below check to check all blocks cleared
606+ // unlink the skeleton for the below check and still find the blocks in blokchain
598607 skeleton [ 'status' ] . linked = false
599608 for ( const block of [ block1 , block2 , block3 , block4 , block5 ] ) {
600609 assert . equal (
601- ( await skeleton . getBlock ( block . header . number , true ) ) ?. hash ( ) ,
602- undefined ,
603- `skeleton block number=${ block . header . number } should be cleaned up after filling canonical chain` ,
610+ ( await skeleton . getBlock ( block . header . number , true ) ) ?. hash ( ) !== undefined ,
611+ true ,
612+ `skeleton block number=${ block . header . number } should be available even afer filling canonical chain` ,
604613 )
605614 assert . equal (
606- ( await skeleton . getBlockByHash ( block . hash ( ) , true ) ) ?. hash ( ) ,
607- undefined ,
615+ ( await skeleton . getBlockByHash ( block . hash ( ) , true ) ) ?. hash ( ) !== undefined ,
616+ true ,
608617 `skeleton block hash=${ short (
609618 block . hash ( ) ,
610- ) } should be cleaned up after filling canonical chain`,
619+ ) } should be available even after filling canonical chain`,
611620 )
612621 }
613622 } )
@@ -677,16 +686,16 @@ describe('[Skeleton] / setHead', async () => {
677686 skeleton [ 'status' ] . linked = false
678687 for ( const block of [ block3 , block4 , block5 ] ) {
679688 assert . equal (
680- ( await skeleton . getBlock ( block . header . number , true ) ) ?. hash ( ) ,
681- undefined ,
682- `skeleton block number=${ block . header . number } should be cleaned up after filling canonical chain` ,
689+ ( await skeleton . getBlock ( block . header . number , true ) ) ?. hash ( ) !== undefined ,
690+ true ,
691+ `skeleton block number=${ block . header . number } should still be available after filling canonical chain` ,
683692 )
684693 assert . equal (
685- ( await skeleton . getBlockByHash ( block . hash ( ) , true ) ) ?. hash ( ) ,
686- undefined ,
694+ ( await skeleton . getBlockByHash ( block . hash ( ) , true ) ) ?. hash ( ) !== undefined ,
695+ true ,
687696 `skeleton block hash=${ short (
688697 block . hash ( ) ,
689- ) } should be cleaned up after filling canonical chain`,
698+ ) } should still be available after filling canonical chain`,
690699 )
691700 }
692701 // restore linkedStatus
@@ -707,9 +716,9 @@ describe('[Skeleton] / setHead', async () => {
707716
708717 await skeleton . setHead ( block41 , false )
709718 await skeleton . setHead ( block51 , false )
710-
711719 // should link the chains including the 41, 51 block backfilled from the unfinalized
712720 await skeleton . forkchoiceUpdate ( block61 )
721+
713722 assert . equal (
714723 skeleton [ 'status' ] . progress . subchains [ 0 ] ?. head ,
715724 BigInt ( 6 ) ,
@@ -856,7 +865,9 @@ describe('[Skeleton] / setHead', async () => {
856865 await skeleton . open ( )
857866
858867 await skeleton . initSync ( block4InvalidPoS )
868+ // the following putBlocks will fail ad block3 is pow block
859869 await skeleton . putBlocks ( [ block3PoW , block2 ] )
870+
860871 assert . equal ( chain . blocks . height , BigInt ( 0 ) , 'canonical height should be at genesis' )
861872 await skeleton . putBlocks ( [ block1 ] )
862873 await wait ( 200 )
0 commit comments