aboutsummaryrefslogtreecommitdiffstats
path: root/tests/helper/vm.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-10-17 00:27:05 +0800
committerobscuren <geffobscura@gmail.com>2014-10-17 00:27:05 +0800
commit93fcabd25189b447cc5c52523134cca2fa1d794e (patch)
tree152b24831fbb2d547bc2189b0b92a2b18c8f64b7 /tests/helper/vm.go
parentbb5038699ef7e08054ef154107e359dce2e3b106 (diff)
downloaddexon-93fcabd25189b447cc5c52523134cca2fa1d794e.tar
dexon-93fcabd25189b447cc5c52523134cca2fa1d794e.tar.gz
dexon-93fcabd25189b447cc5c52523134cca2fa1d794e.tar.bz2
dexon-93fcabd25189b447cc5c52523134cca2fa1d794e.tar.lz
dexon-93fcabd25189b447cc5c52523134cca2fa1d794e.tar.xz
dexon-93fcabd25189b447cc5c52523134cca2fa1d794e.tar.zst
dexon-93fcabd25189b447cc5c52523134cca2fa1d794e.zip
Fixed most of the tests
Diffstat (limited to 'tests/helper/vm.go')
-rw-r--r--tests/helper/vm.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/tests/helper/vm.go b/tests/helper/vm.go
index 4a0d2f8b1..da06b2cc2 100644
--- a/tests/helper/vm.go
+++ b/tests/helper/vm.go
@@ -18,6 +18,7 @@ type Env struct {
number *big.Int
time int64
difficulty *big.Int
+ gasLimit *big.Int
}
func NewEnv(state *ethstate.State) *Env {
@@ -33,7 +34,9 @@ func NewEnvFromMap(state *ethstate.State, envValues map[string]string, exeValues
env.parent = ethutil.Hex2Bytes(envValues["previousHash"])
env.coinbase = ethutil.Hex2Bytes(envValues["currentCoinbase"])
env.number = ethutil.Big(envValues["currentNumber"])
- env.time = ethutil.Big(envValues["currentTime"]).Int64()
+ env.time = ethutil.Big(envValues["currentTimestamp"]).Int64()
+ env.difficulty = ethutil.Big(envValues["currentDifficulty"])
+ env.gasLimit = ethutil.Big(envValues["currentGasLimit"])
return env
}
@@ -46,14 +49,17 @@ func (self *Env) Time() int64 { return self.time }
func (self *Env) Difficulty() *big.Int { return self.difficulty }
func (self *Env) BlockHash() []byte { return nil }
func (self *Env) State() *ethstate.State { return self.state }
+func (self *Env) GasLimit() *big.Int { return self.gasLimit }
func RunVm(state *ethstate.State, env, exec map[string]string) ([]byte, *big.Int, error) {
- caller := state.GetOrNewStateObject(ethutil.Hex2Bytes(exec["caller"]))
- callee := state.GetStateObject(ethutil.Hex2Bytes(exec["address"]))
- closure := ethvm.NewClosure(nil, caller, callee, callee.Code, ethutil.Big(exec["gas"]), ethutil.Big(exec["gasPrice"]))
+ address := FromHex(exec["address"])
+ caller := state.GetOrNewStateObject(FromHex(exec["caller"]))
+ caller.Balance = ethutil.Big(exec["value"])
vm := ethvm.New(NewEnvFromMap(state, env, exec), ethvm.DebugVmTy)
- ret, _, e := closure.Call(vm, nil)
- return ret, closure.Gas, e
+ execution := ethvm.NewExecution(vm, address, FromHex(exec["data"]), ethutil.Big(exec["gas"]), ethutil.Big(exec["gasPrice"]), ethutil.Big(exec["value"]))
+ ret, err := execution.Exec(address, caller)
+
+ return ret, execution.Gas, err
}