aboutsummaryrefslogtreecommitdiffstats
path: root/tests/helper
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-01-12 21:40:40 +0800
committerobscuren <geffobscura@gmail.com>2015-01-12 21:40:40 +0800
commit75cd9cd2de315f8680ff6a382e9b3bd48e17ecad (patch)
tree7bd375c116a705862dfa8a0e32b49e634733d60d /tests/helper
parent00348756bce00c2d19f16ce8df5eff7a62f5cfc6 (diff)
downloaddexon-75cd9cd2de315f8680ff6a382e9b3bd48e17ecad.tar.gz
dexon-75cd9cd2de315f8680ff6a382e9b3bd48e17ecad.tar.zst
dexon-75cd9cd2de315f8680ff6a382e9b3bd48e17ecad.zip
updated tests
Diffstat (limited to 'tests/helper')
-rw-r--r--tests/helper/vm.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/helper/vm.go b/tests/helper/vm.go
index dac279753..797a2acf5 100644
--- a/tests/helper/vm.go
+++ b/tests/helper/vm.go
@@ -1,6 +1,7 @@
package helper
import (
+ "errors"
"math/big"
"github.com/ethereum/go-ethereum/core"
@@ -66,12 +67,16 @@ func (self *Env) AddLog(log state.Log) {
func (self *Env) Depth() int { return self.depth }
func (self *Env) SetDepth(i int) { self.depth = i }
func (self *Env) Transfer(from, to vm.Account, amount *big.Int) error {
+ if self.skipTransfer {
+ if from.Balance().Cmp(amount) < 0 {
+ return errors.New("Insufficient balance in account")
+ }
+ }
return vm.Transfer(from, to, amount)
}
func (self *Env) vm(addr, data []byte, gas, price, value *big.Int) *core.Execution {
exec := core.NewExecution(self, addr, data, gas, price, value)
- exec.SkipTransfer = self.skipTransfer
return exec
}
@@ -104,6 +109,7 @@ func RunVm(state *state.StateDB, env, exec map[string]string) ([]byte, state.Log
)
caller := state.GetOrNewStateObject(from)
+ caller.SetBalance(ethutil.Big("1000000000000000000"))
vmenv := NewEnvFromMap(state, env, exec)
vmenv.skipTransfer = true