Clean up validator tests

This commit is contained in:
Prathamesh Musale 2022-05-17 08:52:19 +05:30
parent ba1ef473f8
commit e55b2b8ab3
2 changed files with 5 additions and 7 deletions

View File

@ -70,7 +70,7 @@ func createLondonTransaction(block *core.BlockGen, addr *common.Address, key *ec
func MakeChain(n int, parent *types.Block, chainGen func(int, *core.BlockGen)) ([]*types.Block, []types.Receipts, *core.BlockChain) { func MakeChain(n int, parent *types.Block, chainGen func(int, *core.BlockGen)) ([]*types.Block, []types.Receipts, *core.BlockChain) {
config := validator.TestChainConfig config := validator.TestChainConfig
blocks, receipts := core.GenerateChain(config, parent, ethash.NewFaker(), Testdb, n, chainGen) blocks, receipts := core.GenerateChain(config, parent, ethash.NewFaker(), Testdb, n, chainGen)
chain, _ := core.NewBlockChain(Testdb, nil, params.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil) chain, _ := core.NewBlockChain(Testdb, nil, validator.TestChainConfig, ethash.NewFaker(), vm.Config{}, nil, nil)
return append([]*types.Block{parent}, blocks...), receipts, chain return append([]*types.Block{parent}, blocks...), receipts, chain
} }
@ -111,7 +111,6 @@ func TestChainGen(i int, block *core.BlockGen) {
block.AddTx(tx) block.AddTx(tx)
case 5: case 5:
block.AddTx(createLondonTransaction(block, &Account1Addr, Account1Key)) block.AddTx(createLondonTransaction(block, &Account1Addr, Account1Key))
case 6: case 6:
block.AddTx(createLondonTransaction(block, &Account2Addr, Account2Key)) block.AddTx(createLondonTransaction(block, &Account2Addr, Account2Key))
} }

View File

@ -7,7 +7,6 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/statediff" "github.com/ethereum/go-ethereum/statediff"
sdtypes "github.com/ethereum/go-ethereum/statediff/types" sdtypes "github.com/ethereum/go-ethereum/statediff/types"
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
@ -32,16 +31,16 @@ var _ = Describe("eth state reading tests", func() {
receipts []types.Receipts receipts []types.Receipts
chain *core.BlockChain chain *core.BlockChain
db *sqlx.DB db *sqlx.DB
chainConfig = params.TestChainConfig chainConfig = validator.TestChainConfig
mockTD = big.NewInt(1337) mockTD = big.NewInt(1337)
) )
It("test init", func() { It("test init", func() {
db = eth.SetupTestDB() db = eth.SetupTestDB()
transformer := eth.SetupTestStateDiffIndexer(context.Background(), chainConfig, test_helpers.Genesis.Hash()) transformer := eth.SetupTestStateDiffIndexer(context.Background(), chainConfig, validator_test.Genesis.Hash())
// make the test blockchain (and state) // make the test blockchain (and state)
blocks, receipts, chain = validator_test.MakeChain(chainLength, test_helpers.Genesis, validator_test.TestChainGen) blocks, receipts, chain = validator_test.MakeChain(chainLength, validator_test.Genesis, validator_test.TestChainGen)
params := statediff.Params{ params := statediff.Params{
IntermediateStateNodes: true, IntermediateStateNodes: true,
IntermediateStorageNodes: true, IntermediateStorageNodes: true,
@ -84,7 +83,7 @@ var _ = Describe("eth state reading tests", func() {
} }
// Insert some non-canonical data into the database so that we test our ability to discern canonicity // Insert some non-canonical data into the database so that we test our ability to discern canonicity
indexAndPublisher := eth.SetupTestStateDiffIndexer(context.Background(), chainConfig, test_helpers.Genesis.Hash()) indexAndPublisher := eth.SetupTestStateDiffIndexer(context.Background(), chainConfig, validator_test.Genesis.Hash())
tx, err := indexAndPublisher.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty()) tx, err := indexAndPublisher.PushBlock(test_helpers.MockBlock, test_helpers.MockReceipts, test_helpers.MockBlock.Difficulty())
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())