From d822e8dc216397b0d935f81ee856b836f681d372 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 1 Feb 2021 16:38:31 +0300 Subject: [PATCH] vm: add test for neo-project/neo-vm#393 --- pkg/vm/vm_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/vm/vm_test.go b/pkg/vm/vm_test.go index 633fd65ce..3dcf0d652 100644 --- a/pkg/vm/vm_test.go +++ b/pkg/vm/vm_test.go @@ -1537,6 +1537,26 @@ func TestHASKEYMap(t *testing.T) { t.Run("False", getTestFuncForVM(prog, false, m, 6)) } +func TestHASKEYBigKey(t *testing.T) { + v := newTestVM() + + buf := io.NewBufBinWriter() + emit.Int(buf.BinWriter, 1024*1024) + emit.Opcodes(buf.BinWriter, opcode.NEWBUFFER, opcode.NEWMAP) + emit.Int(buf.BinWriter, 64) + emit.Opcodes(buf.BinWriter, opcode.NEWBUFFER) + emit.Opcodes(buf.BinWriter, opcode.INITSLOT, opcode.Opcode(0), opcode.Opcode(3)) + + emit.Opcodes(buf.BinWriter, opcode.LDARG1, opcode.LDARG0, opcode.CONVERT, opcode.Opcode(stackitem.ByteArrayT)) + emit.Opcodes(buf.BinWriter, opcode.LDARG0, opcode.SETITEM, opcode.LDARG1, opcode.LDARG2) + emit.Opcodes(buf.BinWriter, opcode.CONVERT, opcode.Opcode(stackitem.ByteArrayT)) + emit.Opcodes(buf.BinWriter, opcode.HASKEY) + + emit.Opcodes(buf.BinWriter, opcode.JMP, opcode.Opcode(0xFB)) // -5 + v.Load(buf.Bytes()) + checkVMFailed(t, v) +} + func TestSIGN(t *testing.T) { prog := makeProgram(opcode.SIGN) t.Run("NoArgument", getTestFuncForVM(prog, nil))