From c1ef19bef9d4207b5f7d6fc5ff40375a5f0d203b Mon Sep 17 00:00:00 2001 From: obscuren Date: Tue, 3 Mar 2015 11:11:11 +0100 Subject: quad mem --- tests/helper/vm.go | 23 ++++++++++++++++++++++- tests/vm/gh_test.go | 10 ++++------ 2 files changed, 26 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/helper/vm.go b/tests/helper/vm.go index f1c1ffdfc..a1a1a98ca 100644 --- a/tests/helper/vm.go +++ b/tests/helper/vm.go @@ -28,6 +28,8 @@ type Env struct { gasLimit *big.Int logs state.Logs + + vmTest bool } func NewEnv(state *state.StateDB) *Env { @@ -92,20 +94,38 @@ func (self *Env) vm(addr, data []byte, gas, price, value *big.Int) *core.Executi } func (self *Env) Call(caller vm.ContextRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error) { + if self.vmTest && self.depth > 0 { + caller.ReturnGas(gas, price) + + return nil, nil + } exe := self.vm(addr, data, gas, price, value) ret, err := exe.Call(addr, caller) self.Gas = exe.Gas return ret, err + } func (self *Env) CallCode(caller vm.ContextRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error) { + if self.vmTest && self.depth > 0 { + caller.ReturnGas(gas, price) + } exe := self.vm(caller.Address(), data, gas, price, value) return exe.Call(addr, caller) } func (self *Env) Create(caller vm.ContextRef, addr, data []byte, gas, price, value *big.Int) ([]byte, error, vm.ContextRef) { exe := self.vm(addr, data, gas, price, value) - return exe.Create(caller) + if self.vmTest { + caller.ReturnGas(gas, price) + + nonce := self.state.GetNonce(caller.Address()) + obj := self.state.GetOrNewStateObject(crypto.CreateAddress(caller.Address(), nonce)) + + return nil, nil, obj + } else { + return exe.Create(caller) + } } func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, state.Logs, *big.Int, error) { @@ -123,6 +143,7 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, state.Log caller := state.GetOrNewStateObject(from) vmenv := NewEnvFromMap(state, env, exec) + vmenv.vmTest = true vmenv.skipTransfer = true vmenv.initial = true ret, err := vmenv.Call(caller, to, data, gas, price, value) diff --git a/tests/vm/gh_test.go b/tests/vm/gh_test.go index a23076b74..f8c42f09c 100644 --- a/tests/vm/gh_test.go +++ b/tests/vm/gh_test.go @@ -79,12 +79,10 @@ func RunVmTest(p string, t *testing.T) { helper.CreateFileTests(t, p, &tests) for name, test := range tests { - /* - helper.Logger.SetLogLevel(4) - if name != "log1_nonEmptyMem_logMemSize1_logMemStart31" { - continue - } - */ + helper.Logger.SetLogLevel(4) + if name != "env1" { + continue + } db, _ := ethdb.NewMemDatabase() statedb := state.New(nil, db) for addr, account := range test.Pre { -- cgit