@@ -25,14 +25,23 @@ type Subchain = {
25
25
}
26
26
27
27
const 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
+ )
31
37
const block50B = createBlock (
32
38
{ 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 } ,
34
44
)
35
- const block51 = createBlock ( { header : { number : 51 , parentHash : block50 . hash ( ) } } , { common } )
36
45
37
46
describe ( '[Skeleton]/ startup scenarios ' , ( ) => {
38
47
it ( 'starts the chain when starting the skeleton' , async ( ) => {
@@ -594,20 +603,20 @@ describe('[Skeleton] / setHead', async () => {
594
603
'canonical height should change when setHead is set with force=true' ,
595
604
)
596
605
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
598
607
skeleton [ 'status' ] . linked = false
599
608
for ( const block of [ block1 , block2 , block3 , block4 , block5 ] ) {
600
609
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` ,
604
613
)
605
614
assert . equal (
606
- ( await skeleton . getBlockByHash ( block . hash ( ) , true ) ) ?. hash ( ) ,
607
- undefined ,
615
+ ( await skeleton . getBlockByHash ( block . hash ( ) , true ) ) ?. hash ( ) !== undefined ,
616
+ true ,
608
617
`skeleton block hash=${ short (
609
618
block . hash ( ) ,
610
- ) } should be cleaned up after filling canonical chain`,
619
+ ) } should be available even after filling canonical chain`,
611
620
)
612
621
}
613
622
} )
@@ -677,16 +686,16 @@ describe('[Skeleton] / setHead', async () => {
677
686
skeleton [ 'status' ] . linked = false
678
687
for ( const block of [ block3 , block4 , block5 ] ) {
679
688
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` ,
683
692
)
684
693
assert . equal (
685
- ( await skeleton . getBlockByHash ( block . hash ( ) , true ) ) ?. hash ( ) ,
686
- undefined ,
694
+ ( await skeleton . getBlockByHash ( block . hash ( ) , true ) ) ?. hash ( ) !== undefined ,
695
+ true ,
687
696
`skeleton block hash=${ short (
688
697
block . hash ( ) ,
689
- ) } should be cleaned up after filling canonical chain`,
698
+ ) } should still be available after filling canonical chain`,
690
699
)
691
700
}
692
701
// restore linkedStatus
@@ -707,9 +716,9 @@ describe('[Skeleton] / setHead', async () => {
707
716
708
717
await skeleton . setHead ( block41 , false )
709
718
await skeleton . setHead ( block51 , false )
710
-
711
719
// should link the chains including the 41, 51 block backfilled from the unfinalized
712
720
await skeleton . forkchoiceUpdate ( block61 )
721
+
713
722
assert . equal (
714
723
skeleton [ 'status' ] . progress . subchains [ 0 ] ?. head ,
715
724
BigInt ( 6 ) ,
@@ -856,7 +865,9 @@ describe('[Skeleton] / setHead', async () => {
856
865
await skeleton . open ( )
857
866
858
867
await skeleton . initSync ( block4InvalidPoS )
868
+ // the following putBlocks will fail ad block3 is pow block
859
869
await skeleton . putBlocks ( [ block3PoW , block2 ] )
870
+
860
871
assert . equal ( chain . blocks . height , BigInt ( 0 ) , 'canonical height should be at genesis' )
861
872
await skeleton . putBlocks ( [ block1 ] )
862
873
await wait ( 200 )
0 commit comments