aboutsummaryrefslogtreecommitdiffstats
path: root/tests/helper/vm.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-02 18:52:56 +0800
committerobscuren <geffobscura@gmail.com>2014-12-02 18:52:56 +0800
commit64f35ba8d1f31d6821a0a1bf946c71396a996f30 (patch)
tree375a081536c7c0b329a3b0c2e812ff05f81dd64c /tests/helper/vm.go
parent616066a598933df7ef126186eb9c647094f665ca (diff)
parent99481a245adc2c4814ab6b38d94d63114f7bbb15 (diff)
downloadgo-tangerine-64f35ba8d1f31d6821a0a1bf946c71396a996f30.tar
go-tangerine-64f35ba8d1f31d6821a0a1bf946c71396a996f30.tar.gz
go-tangerine-64f35ba8d1f31d6821a0a1bf946c71396a996f30.tar.bz2
go-tangerine-64f35ba8d1f31d6821a0a1bf946c71396a996f30.tar.lz
go-tangerine-64f35ba8d1f31d6821a0a1bf946c71396a996f30.tar.xz
go-tangerine-64f35ba8d1f31d6821a0a1bf946c71396a996f30.tar.zst
go-tangerine-64f35ba8d1f31d6821a0a1bf946c71396a996f30.zip
merge errors fixed
Diffstat (limited to 'tests/helper/vm.go')
-rw-r--r--tests/helper/vm.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/helper/vm.go b/tests/helper/vm.go
index 270fe5470..b4ad93193 100644
--- a/tests/helper/vm.go
+++ b/tests/helper/vm.go
@@ -3,6 +3,7 @@ package helper
import (
"math/big"
+ "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/vm"
@@ -66,3 +67,17 @@ func RunVm(state *state.State, env, exec map[string]string) ([]byte, *big.Int, e
return ret, execution.Gas, err
}
+
+func RunState(state *state.State, env, tx map[string]string) ([]byte, *big.Int, error) {
+ address := FromHex(tx["to"])
+ keyPair, _ := crypto.NewKeyPairFromSec([]byte(ethutil.Hex2Bytes(tx["secretKey"])))
+ caller := state.GetOrNewStateObject(keyPair.Address())
+
+ vmenv := NewEnvFromMap(state, env, tx)
+ vmenv.origin = caller.Address()
+ evm := vm.New(vmenv, vm.DebugVmTy)
+ execution := vm.NewExecution(evm, address, FromHex(tx["data"]), ethutil.Big(tx["gasLimit"]), ethutil.Big(tx["gasPrice"]), ethutil.Big(tx["value"]))
+ ret, err := execution.Exec(address, caller)
+
+ return ret, execution.Gas, err
+}