vm: revert SUBSTR offset behavior to NEO 2.x
This commit is contained in:
parent
4c688355bc
commit
9ebb793009
2 changed files with 10 additions and 2 deletions
|
@ -519,7 +519,10 @@ func (v *VM) execute(ctx *Context, op Instruction, parameter []byte) (err error)
|
|||
}
|
||||
s := v.estack.Pop().Bytes()
|
||||
if o > len(s) {
|
||||
panic("invalid offset")
|
||||
// panic("invalid offset")
|
||||
// FIXME revert when NEO 3.0 https://github.com/nspcc-dev/neo-go/issues/477
|
||||
v.estack.PushVal("")
|
||||
break
|
||||
}
|
||||
last := l + o
|
||||
if last > len(s) {
|
||||
|
|
|
@ -1674,7 +1674,12 @@ func TestSUBSTRBadOffset(t *testing.T) {
|
|||
vm.estack.PushVal([]byte("abcdef"))
|
||||
vm.estack.PushVal(7)
|
||||
vm.estack.PushVal(1)
|
||||
checkVMFailed(t, vm)
|
||||
|
||||
// checkVMFailed(t, vm)
|
||||
// FIXME revert when NEO 3.0 https://github.com/nspcc-dev/neo-go/issues/477
|
||||
runVM(t, vm)
|
||||
assert.Equal(t, 1, vm.estack.Len())
|
||||
assert.Equal(t, []byte{}, vm.estack.Peek(0).Bytes())
|
||||
}
|
||||
|
||||
func TestSUBSTRBigLen(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue