diff options
author | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-08-02 08:20:41 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-08-07 18:52:23 +0800 |
commit | 184e9ae9a81df2db6381e18d3daa035d913ae341 (patch) | |
tree | 1404780c9d9772b797ff979594e7468ca382d2b6 /tests/util.go | |
parent | 846f34f78b5f76233655d0cf3611706e99f2efe2 (diff) | |
download | dexon-184e9ae9a81df2db6381e18d3daa035d913ae341.tar dexon-184e9ae9a81df2db6381e18d3daa035d913ae341.tar.gz dexon-184e9ae9a81df2db6381e18d3daa035d913ae341.tar.bz2 dexon-184e9ae9a81df2db6381e18d3daa035d913ae341.tar.lz dexon-184e9ae9a81df2db6381e18d3daa035d913ae341.tar.xz dexon-184e9ae9a81df2db6381e18d3daa035d913ae341.tar.zst dexon-184e9ae9a81df2db6381e18d3daa035d913ae341.zip |
core, tests: reduced state copy by N calls
Reduced the amount of state copied that are required by N calls by doing
a balance check prior to any state modifications.
Diffstat (limited to 'tests/util.go')
-rw-r--r-- | tests/util.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/util.go b/tests/util.go index 6ee1a42db..3b94effc8 100644 --- a/tests/util.go +++ b/tests/util.go @@ -18,7 +18,6 @@ package tests import ( "bytes" - "errors" "fmt" "math/big" @@ -192,18 +191,19 @@ 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 { +func (self *Env) CanTransfer(from vm.Account, balance *big.Int) bool { if self.skipTransfer { - // ugly hack if self.initial { self.initial = false - return nil + return true } + } - if from.Balance().Cmp(amount) < 0 { - return errors.New("Insufficient balance in account") - } + return from.Balance().Cmp(balance) >= 0 +} +func (self *Env) Transfer(from, to vm.Account, amount *big.Int) error { + if self.skipTransfer { return nil } return vm.Transfer(from, to, amount) |