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 -7
View File
@@ -30,7 +30,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth"
@@ -238,7 +237,6 @@ func newTestBackend(t *testing.T) (*node.Node, []*types.Block) {
}
func generateTestChain() []*types.Block {
db := rawdb.NewMemoryDatabase()
generate := func(i int, g *core.BlockGen) {
g.OffsetTime(5)
g.SetExtra([]byte("test"))
@@ -248,11 +246,8 @@ func generateTestChain() []*types.Block {
g.AddTx(testTx2)
}
}
gblock := genesis.MustCommit(db)
engine := ethash.NewFaker()
blocks, _ := core.GenerateChain(genesis.Config, gblock, engine, db, 2, generate)
blocks = append([]*types.Block{gblock}, blocks...)
return blocks
_, blocks, _ := core.GenerateChainWithGenesis(genesis, ethash.NewFaker(), 2, generate)
return append([]*types.Block{genesis.ToBlock()}, blocks...)
}
func TestEthClient(t *testing.T) {
+3 -8
View File
@@ -26,7 +26,6 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth"
@@ -78,10 +77,8 @@ func newTestBackend(t *testing.T) (*node.Node, []*types.Block) {
}
func generateTestChain() (*core.Genesis, []*types.Block) {
db := rawdb.NewMemoryDatabase()
config := params.AllEthashProtocolChanges
genesis := &core.Genesis{
Config: config,
Config: params.AllEthashProtocolChanges,
Alloc: core.GenesisAlloc{testAddr: {Balance: testBalance, Storage: map[common.Hash]common.Hash{testSlot: testValue}}},
ExtraData: []byte("test genesis"),
Timestamp: 9000,
@@ -90,10 +87,8 @@ func generateTestChain() (*core.Genesis, []*types.Block) {
g.OffsetTime(5)
g.SetExtra([]byte("test"))
}
gblock := genesis.MustCommit(db)
engine := ethash.NewFaker()
blocks, _ := core.GenerateChain(config, gblock, engine, db, 1, generate)
blocks = append([]*types.Block{gblock}, blocks...)
_, blocks, _ := core.GenerateChainWithGenesis(genesis, ethash.NewFaker(), 1, generate)
blocks = append([]*types.Block{genesis.ToBlock()}, blocks...)
return genesis, blocks
}