blob: 93ab491fbff618fef1d7addf911255f3cb008316 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
package proto
import (
"bytes"
"encoding/hex"
"testing"
"github.com/stretchr/testify/require"
)
func FuzzQuery_DecodeAware(f *testing.F) {
data, err := hex.DecodeString(queryCreateDatabaseHex)
require.NoError(f, err)
f.Add(data)
f.Fuzz(func(t *testing.T, data []byte) {
var v Query
r := NewReader(bytes.NewReader(data))
_, _ = r.UVarInt() // skip code
if err := v.DecodeAware(r, queryProtoVersion); err != nil {
t.Skip()
}
b := new(Buffer)
v.EncodeAware(b, queryProtoVersion)
br := NewReader(bytes.NewReader(b.Buf))
_, _ = br.UVarInt() // skip code
var dec Query
if err := dec.DecodeAware(br, queryProtoVersion); err != nil {
t.Fatal(err)
}
})
}
|