Merge pull request #1700 from nspcc-dev/add-vm-test-for-big-haskey

vm: add test for neo-project/neo-vm#393
This commit is contained in:
Roman Khimov 2021-02-01 19:15:23 +03:00 committed by GitHub
commit 3e4f4e6dd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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))