aboutsummaryrefslogtreecommitdiffstats
path: root/tests/helper/vm.go
diff options
context:
space:
mode:
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
+}