Skip to content

Commit e376fbf

Browse files
JukLee0irawanwiset25
authored andcommitted
core: cleanup tests (ethereum#25641)
1 parent 6490d35 commit e376fbf

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/chain_makers.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,19 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
244244
return blocks, receipts
245245
}
246246

247+
// GenerateChainWithGenesis is a wrapper of GenerateChain which will initialize
248+
// genesis block to database first according to the provided genesis specification
249+
// then generate chain on top.
250+
func GenerateChainWithGenesis(genesis *Genesis, engine consensus.Engine, n int, gen func(int, *BlockGen)) (ethdb.Database, []*types.Block, []types.Receipts) {
251+
db := rawdb.NewMemoryDatabase()
252+
_, err := genesis.Commit(db)
253+
if err != nil {
254+
panic(err)
255+
}
256+
blocks, receipts := GenerateChain(genesis.Config, genesis.ToBlock(nil), engine, db, n, gen)
257+
return db, blocks, receipts
258+
}
259+
247260
func makeHeader(chain consensus.ChainReader, parent *types.Block, state *state.StateDB, engine consensus.Engine) *types.Header {
248261
var time *big.Int
249262
if parent.Time() == nil {

0 commit comments

Comments
 (0)