all: cleanup tests (#25641)

Follow-up to PR #25523 to cleanup all relevant tests.
This commit is contained in:
rjl493456442
2022-09-07 20:21:59 +02:00
committed by GitHub
parent d30e39b2f8
commit dea1fb3cfc
35 changed files with 427 additions and 639 deletions
+2 -5
View File
@@ -53,13 +53,12 @@ func TestReimportMirroredState(t *testing.T) {
BaseFee: big.NewInt(params.InitialBaseFee),
}
copy(genspec.ExtraData[extraVanity:], addr[:])
genesis := genspec.MustCommit(db)
// Generate a batch of blocks, each properly signed
chain, _ := core.NewBlockChain(db, nil, genspec, nil, engine, vm.Config{}, nil, nil)
chain, _ := core.NewBlockChain(rawdb.NewMemoryDatabase(), nil, genspec, nil, engine, vm.Config{}, nil, nil)
defer chain.Stop()
blocks, _ := core.GenerateChain(params.AllCliqueProtocolChanges, genesis, engine, db, 3, func(i int, block *core.BlockGen) {
_, blocks, _ := core.GenerateChainWithGenesis(genspec, engine, 3, func(i int, block *core.BlockGen) {
// The chain maker doesn't have access to a chain, so the difficulty will be
// lets unset (nil). Set it here to the correct value.
block.SetDifficulty(diffInTurn)
@@ -88,8 +87,6 @@ func TestReimportMirroredState(t *testing.T) {
}
// Insert the first two blocks and make sure the chain is valid
db = rawdb.NewMemoryDatabase()
genspec.MustCommit(db)
chain, _ = core.NewBlockChain(db, nil, genspec, nil, engine, vm.Config{}, nil, nil)
defer chain.Stop()
+4 -6
View File
@@ -401,9 +401,6 @@ func TestClique(t *testing.T) {
for j, signer := range signers {
copy(genesis.ExtraData[extraVanity+j*common.AddressLength:], signer[:])
}
// Create a pristine blockchain with the genesis injected
db := rawdb.NewMemoryDatabase()
genesisBlock := genesis.MustCommit(db)
// Assemble a chain of headers from the cast votes
config := *params.TestChainConfig
@@ -412,10 +409,11 @@ func TestClique(t *testing.T) {
Epoch: tt.epoch,
}
genesis.Config = &config
engine := New(config.Clique, db)
engine := New(config.Clique, rawdb.NewMemoryDatabase())
engine.fakeDiff = true
blocks, _ := core.GenerateChain(&config, genesisBlock, engine, db, len(tt.votes), func(j int, gen *core.BlockGen) {
_, blocks, _ := core.GenerateChainWithGenesis(genesis, engine, len(tt.votes), func(j int, gen *core.BlockGen) {
// Cast the vote contained in this block
gen.SetCoinbase(accounts.address(tt.votes[j].voted))
if tt.votes[j].auth {
@@ -451,7 +449,7 @@ func TestClique(t *testing.T) {
batches[len(batches)-1] = append(batches[len(batches)-1], block)
}
// Pass all the headers through clique and ensure tallying succeeds
chain, err := core.NewBlockChain(db, nil, genesis, nil, engine, vm.Config{}, nil, nil)
chain, err := core.NewBlockChain(rawdb.NewMemoryDatabase(), nil, genesis, nil, engine, vm.Config{}, nil, nil)
if err != nil {
t.Errorf("test %d: failed to create test chain: %v", i, err)
continue