aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-01-12 20:49:47 +0800
committerobscuren <geffobscura@gmail.com>2015-01-12 20:49:47 +0800
commit00348756bce00c2d19f16ce8df5eff7a62f5cfc6 (patch)
treef1512c49e5cc23b390d71a4b5e2df4bd5ad7ee05 /vm
parent35fe4313d57e1df6c3c8af0bc0b530bd7033e21b (diff)
downloaddexon-00348756bce00c2d19f16ce8df5eff7a62f5cfc6.tar
dexon-00348756bce00c2d19f16ce8df5eff7a62f5cfc6.tar.gz
dexon-00348756bce00c2d19f16ce8df5eff7a62f5cfc6.tar.bz2
dexon-00348756bce00c2d19f16ce8df5eff7a62f5cfc6.tar.lz
dexon-00348756bce00c2d19f16ce8df5eff7a62f5cfc6.tar.xz
dexon-00348756bce00c2d19f16ce8df5eff7a62f5cfc6.tar.zst
dexon-00348756bce00c2d19f16ce8df5eff7a62f5cfc6.zip
updated tests
Diffstat (limited to 'vm')
-rw-r--r--vm/context.go7
-rw-r--r--vm/vm_debug.go13
2 files changed, 9 insertions, 11 deletions
diff --git a/vm/context.go b/vm/context.go
index d14df1aa7..b48f1a657 100644
--- a/vm/context.go
+++ b/vm/context.go
@@ -61,6 +61,13 @@ func (c *Context) GetRangeValue(x, size uint64) []byte {
return ethutil.LeftPadBytes(c.Code[x:y], int(size))
}
+func (c *Context) GetCode(x, size uint64) []byte {
+ x = uint64(math.Min(float64(x), float64(len(c.Code))))
+ y := uint64(math.Min(float64(x+size), float64(len(c.Code))))
+
+ return ethutil.RightPadBytes(c.Code[x:y], int(size))
+}
+
func (c *Context) Return(ret []byte) []byte {
// Return the remaining gas to the caller
c.caller.ReturnGas(c.Gas, c.Price)
diff --git a/vm/vm_debug.go b/vm/vm_debug.go
index 04ba8190d..eec8c518f 100644
--- a/vm/vm_debug.go
+++ b/vm/vm_debug.go
@@ -2,7 +2,6 @@ package vm
import (
"fmt"
- "math"
"math/big"
"github.com/ethereum/go-ethereum/crypto"
@@ -491,21 +490,13 @@ func (self *DebugVm) Run(me, caller ContextRef, code []byte, value, gas, price *
} else {
code = context.Code
}
-
+ context := NewContext(nil, nil, code, ethutil.Big0, ethutil.Big0)
var (
- size = uint64(len(code))
mOff = stack.Pop().Uint64()
cOff = stack.Pop().Uint64()
l = stack.Pop().Uint64()
)
-
- if cOff > size {
- cOff = 0
- l = 0
- } else if cOff+l > size {
- l = uint64(math.Min(float64(cOff+l), float64(size)))
- }
- codeCopy := code[cOff : cOff+l]
+ codeCopy := context.GetCode(cOff, l)
mem.Set(mOff, l, codeCopy)