diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index 4b56d1f8f..ba11b3e80 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -615,15 +615,9 @@ func (v *VM) execute(ctx *Context, op opcode.Opcode, parameter []byte) (err erro panic("negative index") } s := v.estack.Pop().Bytes() - if o > len(s) { - // 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) { - last = len(s) + panic("invalid offset") } v.estack.PushVal(s[o:last]) diff --git a/pkg/vm/vm_test.go b/pkg/vm/vm_test.go index e1572e22e..7b911d5d8 100644 --- a/pkg/vm/vm_test.go +++ b/pkg/vm/vm_test.go @@ -2267,11 +2267,7 @@ func TestSUBSTRBadOffset(t *testing.T) { vm.estack.PushVal(7) vm.estack.PushVal(1) - // 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()) + checkVMFailed(t, vm) } func TestSUBSTRBigLen(t *testing.T) { @@ -2280,9 +2276,7 @@ func TestSUBSTRBigLen(t *testing.T) { vm.estack.PushVal([]byte("abcdef")) vm.estack.PushVal(1) vm.estack.PushVal(6) - runVM(t, vm) - assert.Equal(t, 1, vm.estack.Len()) - assert.Equal(t, []byte("bcdef"), vm.estack.Pop().Bytes()) + checkVMFailed(t, vm) } func TestSUBSTRBad387(t *testing.T) { @@ -2293,9 +2287,7 @@ func TestSUBSTRBad387(t *testing.T) { vm.estack.PushVal(b) vm.estack.PushVal(1) vm.estack.PushVal(6) - runVM(t, vm) - assert.Equal(t, 1, vm.estack.Len()) - assert.Equal(t, []byte("bcdef"), vm.estack.Pop().Bytes()) + checkVMFailed(t, vm) } func TestSUBSTRBadNegativeOffset(t *testing.T) {