mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 09:23:48 +00:00
tests: add dummy ChainContext impl to read config
This commit is contained in:
parent
b16db48789
commit
d47bcafb30
2 changed files with 12 additions and 2 deletions
|
|
@ -303,7 +303,7 @@ func runBenchmark(b *testing.B, t *StateTest) {
|
|||
|
||||
// Prepare the EVM.
|
||||
txContext := core.NewEVMTxContext(msg)
|
||||
context := core.NewEVMBlockContext(block.Header(), nil, &t.json.Env.Coinbase)
|
||||
context := core.NewEVMBlockContext(block.Header(), &dummyChain{config: config}, &t.json.Env.Coinbase)
|
||||
context.GetHash = vmTestBlockHash
|
||||
context.BaseFee = baseFee
|
||||
evm := vm.NewEVM(context, state.StateDB, config, vmconfig)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import (
|
|||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/common/math"
|
||||
"github.com/ethereum/go-ethereum/consensus"
|
||||
"github.com/ethereum/go-ethereum/consensus/misc/eip4844"
|
||||
"github.com/ethereum/go-ethereum/core"
|
||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||
|
|
@ -299,7 +300,7 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh
|
|||
}
|
||||
|
||||
// Prepare the EVM.
|
||||
context := core.NewEVMBlockContext(block.Header(), nil, &t.json.Env.Coinbase)
|
||||
context := core.NewEVMBlockContext(block.Header(), &dummyChain{config: config}, &t.json.Env.Coinbase)
|
||||
context.GetHash = vmTestBlockHash
|
||||
context.BaseFee = baseFee
|
||||
context.Random = nil
|
||||
|
|
@ -548,3 +549,12 @@ func (st *StateTestState) Close() {
|
|||
st.Snapshots = nil
|
||||
}
|
||||
}
|
||||
|
||||
// dummyChain implements the core.ChainContext interface.
|
||||
type dummyChain struct {
|
||||
config *params.ChainConfig
|
||||
}
|
||||
|
||||
func (d *dummyChain) Engine() consensus.Engine { return nil }
|
||||
func (d *dummyChain) GetHeader(h common.Hash, n uint64) *types.Header { return nil }
|
||||
func (d *dummyChain) Config() *params.ChainConfig { return d.config }
|
||||
|
|
|
|||
Loading…
Reference in a new issue