File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ func (c *codecImpl) encodeDBNode(n *dbNode) []byte {
98
98
estimatedLen = estimatedValueLen + minVarIntLen + estimatedNodeChildLen * numChildren
99
99
buf = bytes .NewBuffer (make ([]byte , 0 , estimatedLen ))
100
100
)
101
+
101
102
c .encodeMaybeByteSlice (buf , n .value )
102
103
c .encodeUint (buf , uint64 (numChildren ))
103
104
// Note we insert children in order of increasing index
Original file line number Diff line number Diff line change @@ -71,6 +71,33 @@ func FuzzCodecInt(f *testing.F) {
71
71
)
72
72
}
73
73
74
+ func FuzzCodecKey (f * testing.F ) {
75
+ f .Fuzz (
76
+ func (
77
+ t * testing.T ,
78
+ b []byte ,
79
+ ) {
80
+ require := require .New (t )
81
+ codec := codec .(* codecImpl )
82
+ reader := bytes .NewReader (b )
83
+ startLen := reader .Len ()
84
+ got , err := codec .decodeKey (reader )
85
+ if err != nil {
86
+ t .SkipNow ()
87
+ }
88
+ endLen := reader .Len ()
89
+ numRead := startLen - endLen
90
+
91
+ // Encoding [got] should be the same as [b].
92
+ var buf bytes.Buffer
93
+ codec .encodeKey (& buf , got )
94
+ bufBytes := buf .Bytes ()
95
+ require .Len (bufBytes , numRead )
96
+ require .Equal (b [:numRead ], bufBytes )
97
+ },
98
+ )
99
+ }
100
+
74
101
func FuzzCodecDBNodeCanonical (f * testing.F ) {
75
102
f .Fuzz (
76
103
func (
You can’t perform that action at this time.
0 commit comments