diff options
author | obscuren <geffobscura@gmail.com> | 2015-03-03 18:11:11 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-03-03 18:11:11 +0800 |
commit | c1ef19bef9d4207b5f7d6fc5ff40375a5f0d203b (patch) | |
tree | ec0d2325fc2c4e53050ba7b52222eacf6030a289 /tests | |
parent | fe7ab662f0f1d17a4f350e344756da9e31790d45 (diff) | |
download | go-tangerine-c1ef19bef9d4207b5f7d6fc5ff40375a5f0d203b.tar go-tangerine-c1ef19bef9d4207b5f7d6fc5ff40375a5f0d203b.tar.gz go-tangerine-c1ef19bef9d4207b5f7d6fc5ff40375a5f0d203b.tar.bz2 go-tangerine-c1ef19bef9d4207b5f7d6fc5ff40375a5f0d203b.tar.lz go-tangerine-c1ef19bef9d4207b5f7d6fc5ff40375a5f0d203b.tar.xz go-tangerine-c1ef19bef9d4207b5f7d6fc5ff40375a5f0d203b.tar.zst go-tangerine-c1ef19bef9d4207b5f7d6fc5ff40375a5f0d203b.zip |
quad mem
Diffstat (limited to 'tests')
-rw-r--r-- | tests/helper/vm.go | 23 | ||||
-rw-r--r-- | tests/vm/gh_test.go | 10 |
2 files changed, 26 insertions, 7 deletions
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 { |