all: move genesis initialization to blockchain (#25523)

* all: move genesis initialization to blockchain

* core: add one more check

* core: fix tests
This commit is contained in:
rjl493456442
2022-08-30 18:22:28 +02:00
committed by GitHub
parent 2b6df280de
commit d10c280309
35 changed files with 406 additions and 245 deletions
+4 -3
View File
@@ -63,12 +63,13 @@ func newTestBackend(blocks int) *testBackend {
func newTestBackendWithGenerator(blocks int, generator func(int, *core.BlockGen)) *testBackend {
// Create a database pre-initialize with a genesis block
db := rawdb.NewMemoryDatabase()
(&core.Genesis{
gspec := &core.Genesis{
Config: params.TestChainConfig,
Alloc: core.GenesisAlloc{testAddr: {Balance: big.NewInt(100_000_000_000_000_000)}},
}).MustCommit(db)
}
gspec.MustCommit(db)
chain, _ := core.NewBlockChain(db, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil)
chain, _ := core.NewBlockChain(db, nil, gspec, nil, ethash.NewFaker(), vm.Config{}, nil, nil)
bs, _ := core.GenerateChain(params.TestChainConfig, chain.Genesis(), ethash.NewFaker(), db, blocks, generator)
if _, err := chain.InsertChain(bs); err != nil {