Compare commits

..

3 commits

Author SHA1 Message Date
470ec29a6c Fix fuzzing functions
Signed-off-by: Roman Ognev <r.ognev@yadro.com>
2024-09-23 19:49:08 +03:00
bb4aacdd39 Fix fuzzing functions
Signed-off-by: Roman Ognev <r.ognev@yadro.com>
2024-09-23 12:55:55 +03:00
87160a5919 Fix fuzzing functions
Signed-off-by: Roman Ognev <r.ognev@yadro.com>
2024-09-23 11:49:46 +03:00
2 changed files with 21 additions and 20 deletions

View file

@ -3,7 +3,10 @@
package chain
func DoFuzzChainUnmarshalBinary(data []byte) int {
func InitFuzzUnmarshal() {
}
func DoFuzzUnmarshal(data []byte) int {
var ch Chain
err := ch.UnmarshalBinary(data)
if err != nil {

View file

@ -5,30 +5,28 @@ package chain
import (
"testing"
"github.com/stretchr/testify/require"
)
func FuzzUnmarshal(f *testing.F) {
for _, id := range generateTestIDs() {
for _, rules := range generateTestRules() {
for _, matchType := range generateTestMatchTypes() {
// for _, id := range generateTestIDs() {
// for _, rules := range generateTestRules() {
// for _, matchType := range generateTestMatchTypes() {
chain := Chain{
ID: id,
Rules: rules,
MatchType: matchType,
}
data, err := chain.MarshalBinary()
require.NoError(f, err)
f.Add(data)
}
}
}
// chain := Chain{
// ID: id,
// Rules: rules,
// MatchType: matchType,
// }
// data, err := chain.MarshalBinary()
// require.NoError(f, err)
// f.Add(data)
// }
// }
// }
f.Fuzz(func(t *testing.T, data []byte) {
require.NotPanics(t, func() {
DoFuzzChainUnmarshalBinary(data)
})
// require.NotPanics(t, func() {
DoFuzzUnmarshal(data)
// })
})
}