diff options
author | jm <jm.huang@cobinhood.com> | 2019-01-16 17:32:29 +0800 |
---|---|---|
committer | Jhih-Ming Huang <jm.huang@cobinhood.com> | 2019-03-26 17:48:21 +0800 |
commit | 1810c3af03d3da56d42f93c4521e33332156dcb6 (patch) | |
tree | 1cbcce4df7b1c5c50486c802abe4d37fb7cd70a6 /tests | |
parent | d62272c95d13fd4928e5c14794c25f671a71bd95 (diff) | |
download | dexon-1810c3af03d3da56d42f93c4521e33332156dcb6.tar dexon-1810c3af03d3da56d42f93c4521e33332156dcb6.tar.gz dexon-1810c3af03d3da56d42f93c4521e33332156dcb6.tar.bz2 dexon-1810c3af03d3da56d42f93c4521e33332156dcb6.tar.lz dexon-1810c3af03d3da56d42f93c4521e33332156dcb6.tar.xz dexon-1810c3af03d3da56d42f93c4521e33332156dcb6.tar.zst dexon-1810c3af03d3da56d42f93c4521e33332156dcb6.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 { |