@@ -44,16 +44,16 @@ import (
4444// are also returned in case more test blocks are needed later.
4545func newCanonical (engine consensus.Engine , n int , full bool ) (ethdb.Database , * BlockChain , error ) {
4646 var (
47+ db = rawdb .NewMemoryDatabase ()
4748 gspec = & Genesis {
4849 BaseFee : big .NewInt (params .InitialBaseFee ),
4950 Config : params .AllEthashProtocolChanges ,
5051 }
52+ genesis = gspec .MustCommit (db )
5153 )
52- db := rawdb .NewMemoryDatabase ()
53- genesis := gspec .MustCommit (db )
5454
5555 // Initialize a fresh chain with only a genesis block
56- blockchain , _ := NewBlockChain (db , nil , params . AllEthashProtocolChanges , engine , vm.Config {})
56+ blockchain , _ := NewBlockChain (db , nil , gspec , engine , vm.Config {})
5757
5858 // Create and inject the requested chain
5959 if n == 0 {
@@ -517,7 +517,11 @@ func testReorgBadHashes(t *testing.T, full bool) {
517517 blockchain .Stop ()
518518
519519 // Create a new BlockChain and check that it rolled back the state.
520- ncm , err := NewBlockChain (blockchain .db , nil , blockchain .chainConfig , ethash .NewFaker (), vm.Config {})
520+ gspec := & Genesis {
521+ BaseFee : big .NewInt (params .InitialBaseFee ),
522+ Config : params .AllEthashProtocolChanges ,
523+ }
524+ ncm , err := NewBlockChain (blockchain .db , nil , gspec , ethash .NewFaker (), vm.Config {})
521525 if err != nil {
522526 t .Fatalf ("failed to create new chain manager: %v" , err )
523527 }
@@ -620,7 +624,7 @@ func TestFastVsFullChains(t *testing.T) {
620624 // Import the chain as an archive node for the comparison baseline
621625 archiveDb := rawdb .NewMemoryDatabase ()
622626 gspec .MustCommit (archiveDb )
623- archive , _ := NewBlockChain (archiveDb , nil , gspec . Config , ethash .NewFaker (), vm.Config {})
627+ archive , _ := NewBlockChain (archiveDb , nil , gspec , ethash .NewFaker (), vm.Config {})
624628 defer archive .Stop ()
625629
626630 if n , err := archive .InsertChain (blocks ); err != nil {
@@ -629,7 +633,7 @@ func TestFastVsFullChains(t *testing.T) {
629633 // Fast import the chain as a non-archive node to test
630634 fastDb := rawdb .NewMemoryDatabase ()
631635 gspec .MustCommit (fastDb )
632- fast , _ := NewBlockChain (fastDb , nil , gspec . Config , ethash .NewFaker (), vm.Config {})
636+ fast , _ := NewBlockChain (fastDb , nil , gspec , ethash .NewFaker (), vm.Config {})
633637 defer fast .Stop ()
634638
635639 headers := make ([]* types.Header , len (blocks ))
@@ -711,7 +715,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) {
711715 archiveDb := rawdb .NewMemoryDatabase ()
712716 gspec .MustCommit (archiveDb )
713717
714- archive , _ := NewBlockChain (archiveDb , nil , gspec . Config , ethash .NewFaker (), vm.Config {})
718+ archive , _ := NewBlockChain (archiveDb , nil , gspec , ethash .NewFaker (), vm.Config {})
715719 if n , err := archive .InsertChain (blocks ); err != nil {
716720 t .Fatalf ("failed to process block %d: %v" , n , err )
717721 }
@@ -724,7 +728,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) {
724728 // Import the chain as a non-archive node and ensure all pointers are updated
725729 fastDb := rawdb .NewMemoryDatabase ()
726730 gspec .MustCommit (fastDb )
727- fast , _ := NewBlockChain (fastDb , nil , gspec . Config , ethash .NewFaker (), vm.Config {})
731+ fast , _ := NewBlockChain (fastDb , nil , gspec , ethash .NewFaker (), vm.Config {})
728732 defer fast .Stop ()
729733
730734 headers := make ([]* types.Header , len (blocks ))
@@ -745,7 +749,7 @@ func TestLightVsFastVsFullChainHeads(t *testing.T) {
745749 lightDb := rawdb .NewMemoryDatabase ()
746750 gspec .MustCommit (lightDb )
747751
748- light , _ := NewBlockChain (lightDb , nil , gspec . Config , ethash .NewFaker (), vm.Config {})
752+ light , _ := NewBlockChain (lightDb , nil , gspec , ethash .NewFaker (), vm.Config {})
749753 if n , err := light .InsertHeaderChain (headers , 1 ); err != nil {
750754 t .Fatalf ("failed to insert header %d: %v" , n , err )
751755 }
@@ -814,7 +818,7 @@ func TestChainTxReorgs(t *testing.T) {
814818 }
815819 })
816820 // Import the chain. This runs all block validation rules.
817- blockchain , _ := NewBlockChain (db , nil , gspec . Config , ethash .NewFaker (), vm.Config {})
821+ blockchain , _ := NewBlockChain (db , nil , gspec , ethash .NewFaker (), vm.Config {})
818822 if i , err := blockchain .InsertChain (chain ); err != nil {
819823 t .Fatalf ("failed to insert original chain[%d]: %v" , i , err )
820824 }
@@ -887,7 +891,7 @@ func TestLogReorgs(t *testing.T) {
887891 signer = types .LatestSigner (gspec .Config )
888892 )
889893
890- blockchain , _ := NewBlockChain (db , nil , gspec . Config , ethash .NewFaker (), vm.Config {})
894+ blockchain , _ := NewBlockChain (db , nil , gspec , ethash .NewFaker (), vm.Config {})
891895 defer blockchain .Stop ()
892896
893897 rmLogsCh := make (chan RemovedLogsEvent )
@@ -1066,7 +1070,7 @@ func TestEIP155Transition(t *testing.T) {
10661070 genesis = gspec .MustCommit (db )
10671071 )
10681072
1069- blockchain , _ := NewBlockChain (db , nil , gspec . Config , ethash .NewFaker (), vm.Config {})
1073+ blockchain , _ := NewBlockChain (db , nil , gspec , ethash .NewFaker (), vm.Config {})
10701074 defer blockchain .Stop ()
10711075
10721076 blocks , _ := GenerateChain (gspec .Config , genesis , ethash .NewFaker (), db , 4 , func (i int , block * BlockGen ) {
@@ -1173,7 +1177,7 @@ func TestEIP161AccountRemoval(t *testing.T) {
11731177 }
11741178 genesis = gspec .MustCommit (db )
11751179 )
1176- blockchain , _ := NewBlockChain (db , nil , gspec . Config , ethash .NewFaker (), vm.Config {})
1180+ blockchain , _ := NewBlockChain (db , nil , gspec , ethash .NewFaker (), vm.Config {})
11771181 defer blockchain .Stop ()
11781182
11791183 blocks , _ := GenerateChain (gspec .Config , genesis , ethash .NewFaker (), db , 3 , func (i int , block * BlockGen ) {
@@ -1252,7 +1256,7 @@ func TestBlockchainHeaderchainReorgConsistency(t *testing.T) {
12521256 diskdb := rawdb .NewMemoryDatabase ()
12531257 gspec .MustCommit (diskdb )
12541258
1255- chain , err := NewBlockChain (diskdb , nil , gspec . Config , engine , vm.Config {})
1259+ chain , err := NewBlockChain (diskdb , nil , gspec , engine , vm.Config {})
12561260 if err != nil {
12571261 t .Fatalf ("failed to create tester chain: %v" , err )
12581262 }
@@ -1300,7 +1304,7 @@ func TestTrieForkGC(t *testing.T) {
13001304 diskdb := rawdb .NewMemoryDatabase ()
13011305 gspec .MustCommit (diskdb )
13021306
1303- chain , err := NewBlockChain (diskdb , nil , gspec . Config , engine , vm.Config {})
1307+ chain , err := NewBlockChain (diskdb , nil , gspec , engine , vm.Config {})
13041308 if err != nil {
13051309 t .Fatalf ("failed to create tester chain: %v" , err )
13061310 }
@@ -1327,12 +1331,12 @@ func TestTrieForkGC(t *testing.T) {
13271331func TestLargeReorgTrieGC (t * testing.T ) {
13281332 // Generate the original common chain segment and the two competing forks
13291333 engine := ethash .NewFaker ()
1334+
1335+ db := rawdb .NewMemoryDatabase ()
13301336 gspec := & Genesis {
13311337 BaseFee : big .NewInt (params .InitialBaseFee ),
13321338 Config : params .TestChainConfig ,
13331339 }
1334-
1335- db := rawdb .NewMemoryDatabase ()
13361340 genesis := gspec .MustCommit (db )
13371341
13381342 shared , _ := GenerateChain (gspec .Config , genesis , engine , db , 64 , func (i int , b * BlockGen ) { b .SetCoinbase (common.Address {1 }) })
@@ -1343,7 +1347,7 @@ func TestLargeReorgTrieGC(t *testing.T) {
13431347 diskdb := rawdb .NewMemoryDatabase ()
13441348 gspec .MustCommit (diskdb )
13451349
1346- chain , err := NewBlockChain (diskdb , nil , gspec . Config , engine , vm.Config {})
1350+ chain , err := NewBlockChain (diskdb , nil , gspec , engine , vm.Config {})
13471351 if err != nil {
13481352 t .Fatalf ("failed to create tester chain: %v" , err )
13491353 }
@@ -1425,7 +1429,7 @@ func benchmarkLargeNumberOfValueToNonexisting(b *testing.B, numTxs, numBlocks in
14251429 diskdb := rawdb .NewMemoryDatabase ()
14261430 gspec .MustCommit (diskdb )
14271431
1428- chain , err := NewBlockChain (diskdb , nil , gspec . Config , engine , vm.Config {})
1432+ chain , err := NewBlockChain (diskdb , nil , gspec , engine , vm.Config {})
14291433 if err != nil {
14301434 b .Fatalf ("failed to create tester chain: %v" , err )
14311435 }
@@ -1652,7 +1656,7 @@ func TestEIP2718Transition(t *testing.T) {
16521656 diskdb := rawdb .NewMemoryDatabase ()
16531657 gspec .MustCommit (diskdb )
16541658
1655- chain , err := NewBlockChain (diskdb , nil , gspec . Config , engine , vm.Config {})
1659+ chain , err := NewBlockChain (diskdb , nil , gspec , engine , vm.Config {})
16561660 if err != nil {
16571661 t .Fatalf ("failed to create tester chain: %v" , err )
16581662 }
@@ -1747,7 +1751,7 @@ func TestTransientStorageReset(t *testing.T) {
17471751 gspec .MustCommit (diskdb )
17481752
17491753 // Initialize the blockchain with 1153 enabled.
1750- chain , err := NewBlockChain (diskdb , nil , gspec . Config , engine , vmConfig )
1754+ chain , err := NewBlockChain (diskdb , nil , gspec , engine , vmConfig )
17511755 if err != nil {
17521756 t .Fatalf ("failed to create tester chain: %v" , err )
17531757 }
@@ -1842,7 +1846,7 @@ func TestEIP3651(t *testing.T) {
18421846 diskdb := rawdb .NewMemoryDatabase ()
18431847 gspec .MustCommit (diskdb )
18441848
1845- chain , err := NewBlockChain (diskdb , nil , gspec . Config , engine , vm.Config {})
1849+ chain , err := NewBlockChain (diskdb , nil , gspec , engine , vm.Config {})
18461850 if err != nil {
18471851 t .Fatalf ("failed to create tester chain: %v" , err )
18481852 }
@@ -1945,7 +1949,7 @@ func TestDeleteCreateRevert(t *testing.T) {
19451949 diskdb := rawdb .NewMemoryDatabase ()
19461950 gspec .MustCommit (diskdb )
19471951
1948- chain , err := NewBlockChain (diskdb , nil , gspec . Config , engine , vm.Config {})
1952+ chain , err := NewBlockChain (diskdb , nil , gspec , engine , vm.Config {})
19491953 if err != nil {
19501954 t .Fatalf ("failed to create tester chain: %v" , err )
19511955 }
0 commit comments