Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions miner/algo_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,22 +186,27 @@ func genGenesisAlloc(sign signerList, contractAddr []common.Address, contractCod

func genTestSetup() (*state.StateDB, chainData, signerList) {
config := params.AllEthashProtocolChanges
db := rawdb.NewMemoryDatabase()
signerList := genSignerList(10, config)

signerList := genSignerList(10, params.AllEthashProtocolChanges)
genesisAlloc := genGenesisAlloc(signerList, []common.Address{payProxyAddress, logContractAddress}, [][]byte{payProxyCode, logContractCode})

stateDB, chainData := genTestSetupWithAlloc(config, genesisAlloc)
return stateDB, chainData, signerList
}

func genTestSetupWithAlloc(config *params.ChainConfig, alloc core.GenesisAlloc) (*state.StateDB, chainData) {
db := rawdb.NewMemoryDatabase()

gspec := &core.Genesis{
Config: config,
Alloc: genesisAlloc,
Alloc: alloc,
}
_ = gspec.MustCommit(db)

chain, _ := core.NewBlockChain(db, &core.CacheConfig{TrieDirtyDisabled: true}, gspec.Config, ethash.NewFaker(), vm.Config{}, nil, nil)

stateDB, _ := state.New(chain.CurrentHeader().Root, state.NewDatabase(db), nil)

return stateDB, chainData{config, chain, nil}, signerList
return stateDB, chainData{config, chain, nil}
}

func newEnvironment(data chainData, state *state.StateDB, coinbase common.Address, gasLimit uint64, baseFee *big.Int) *environment {
Expand Down
Loading