Merge pull request #3501 from NeoGoBros/add-max-array-size-test

Add a missing `mptdata` test
This commit is contained in:
Anna Shaleva 2024-07-03 19:34:14 +03:00 committed by GitHub
commit 5566e354d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -21,4 +21,18 @@ func TestMPTData_EncodeDecodeBinary(t *testing.T) {
} }
testserdes.EncodeDecodeBinary(t, d, new(MPTData)) testserdes.EncodeDecodeBinary(t, d, new(MPTData))
}) })
t.Run("exceeds MaxArraySize", func(t *testing.T) {
bytes := []byte{
// The first byte represents the number 0x1.
// It encodes the size of the outer array (the number or rows in the Nodes matrix).
0x1,
// This sequence of 9 bytes represents the number 0xffffffffffffffff.
// It encodes the size of the first row in the Nodes matrix.
// This size exceeds the maximum array size, thus the decoder should
// return an error.
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
}
require.Error(t, testserdes.DecodeBinary(bytes, new(MPTData)))
})
} }