diff options
author | jm <jm.huang@cobinhood.com> | 2019-01-16 17:32:29 +0800 |
---|---|---|
committer | Jhih-Ming Huang <jm.huang@cobinhood.com> | 2019-05-06 10:44:03 +0800 |
commit | d3b485a5af768db59bd648175849f961e25bc630 (patch) | |
tree | ec43033c9aa438969cea45fb9de19e50a88a5cd8 /tests | |
parent | 266068a53cdf9e06acacf982d63653c03133a634 (diff) | |
download | dexon-d3b485a5af768db59bd648175849f961e25bc630.tar dexon-d3b485a5af768db59bd648175849f961e25bc630.tar.gz dexon-d3b485a5af768db59bd648175849f961e25bc630.tar.bz2 dexon-d3b485a5af768db59bd648175849f961e25bc630.tar.lz dexon-d3b485a5af768db59bd648175849f961e25bc630.tar.xz dexon-d3b485a5af768db59bd648175849f961e25bc630.tar.zst dexon-d3b485a5af768db59bd648175849f961e25bc630.zip |
core: vm: extract stateDB and contract out
Extract stateDB and contract out from core/vm/evm to core/vm,
such that other vm type can use the common modules.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/vm_test_util.go | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/tests/vm_test_util.go b/tests/vm_test_util.go index 316213ea5..09b30d19b 100644 --- a/tests/vm_test_util.go +++ b/tests/vm_test_util.go @@ -27,7 +27,8 @@ import ( "github.com/dexon-foundation/dexon/common/math" "github.com/dexon-foundation/dexon/core" "github.com/dexon-foundation/dexon/core/state" - vm "github.com/dexon-foundation/dexon/core/vm/evm" + "github.com/dexon-foundation/dexon/core/vm" + "github.com/dexon-foundation/dexon/core/vm/evm" "github.com/dexon-foundation/dexon/crypto" "github.com/dexon-foundation/dexon/ethdb" "github.com/dexon-foundation/dexon/params" @@ -78,7 +79,7 @@ type vmExecMarshaling struct { GasPrice *math.HexOrDecimal256 } -func (t *VMTest) Run(vmconfig vm.Config) error { +func (t *VMTest) Run(vmconfig evm.Config) error { statedb := MakePreState(ethdb.NewMemDatabase(), t.json.Pre) ret, gasRemaining, err := t.exec(statedb, vmconfig) @@ -114,13 +115,13 @@ func (t *VMTest) Run(vmconfig vm.Config) error { return nil } -func (t *VMTest) exec(statedb *state.StateDB, vmconfig vm.Config) ([]byte, uint64, error) { +func (t *VMTest) exec(statedb *state.StateDB, vmconfig evm.Config) ([]byte, uint64, error) { evm := t.newEVM(statedb, vmconfig) e := t.json.Exec return evm.Call(vm.AccountRef(e.Caller), e.Address, e.Data, e.GasLimit, e.Value) } -func (t *VMTest) newEVM(statedb *state.StateDB, vmconfig vm.Config) *vm.EVM { +func (t *VMTest) newEVM(statedb *state.StateDB, vmconfig evm.Config) *evm.EVM { initialCall := true canTransfer := func(db vm.StateDB, address common.Address, amount *big.Int) bool { if initialCall { @@ -143,7 +144,7 @@ func (t *VMTest) newEVM(statedb *state.StateDB, vmconfig vm.Config) *vm.EVM { GasPrice: t.json.Exec.GasPrice, } vmconfig.NoRecursion = true - return vm.NewEVM(context, statedb, params.EthereumMainnetChainConfig, vmconfig) + return evm.NewEVM(context, statedb, params.EthereumMainnetChainConfig, vmconfig) } func vmTestBlockHash(n uint64) common.Hash { |