diff options
Diffstat (limited to 'tests/state_test_util.go')
-rw-r--r-- | tests/state_test_util.go | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 117bb4b28..dc5872d98 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -18,7 +18,6 @@ package tests import ( "bytes" - "encoding/hex" "fmt" "io" "math/big" @@ -29,9 +28,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" - "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/params" @@ -207,39 +204,21 @@ func runStateTest(chainConfig *params.ChainConfig, test VmTest) error { } func RunState(chainConfig *params.ChainConfig, statedb *state.StateDB, env, tx map[string]string) ([]byte, vm.Logs, *big.Int, error) { - var ( - data = common.FromHex(tx["data"]) - gas = common.Big(tx["gasLimit"]) - price = common.Big(tx["gasPrice"]) - value = common.Big(tx["value"]) - nonce = common.Big(tx["nonce"]).Uint64() - ) - - var to *common.Address - if len(tx["to"]) > 2 { - t := common.HexToAddress(tx["to"]) - to = &t - } + environment, msg := NewEVMEnvironment(false, chainConfig, statedb, env, tx) // Set pre compiled contracts vm.Precompiled = vm.PrecompiledContracts() gaspool := new(core.GasPool).AddGas(common.Big(env["currentGasLimit"])) - key, _ := hex.DecodeString(tx["secretKey"]) - addr := crypto.PubkeyToAddress(crypto.ToECDSA(key).PublicKey) - message := types.NewMessage(addr, to, nonce, value, gas, price, data, true) - vmenv := NewEnvFromMap(chainConfig, statedb, env, tx) - vmenv.origin = addr - root, _ := statedb.Commit(false) statedb.Reset(root) snapshot := statedb.Snapshot() - ret, _, err := core.ApplyMessage(vmenv, message, gaspool) + ret, gasUsed, err := core.ApplyMessage(environment, msg, gaspool) if core.IsNonceErr(err) || core.IsInvalidTxErr(err) || core.IsGasLimitErr(err) { statedb.RevertToSnapshot(snapshot) } - statedb.Commit(chainConfig.IsEIP158(vmenv.BlockNumber())) + statedb.Commit(chainConfig.IsEIP158(environment.Context.BlockNumber)) - return ret, vmenv.state.Logs(), vmenv.Gas, err + return ret, statedb.Logs(), gasUsed, err } |