2022-03-24 14:15:43 +00:00
|
|
|
package network
|
|
|
|
|
|
|
|
import (
|
|
|
|
"math/rand"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func FuzzMessageDecode(f *testing.F) {
|
|
|
|
for i := 0; i < 100; i++ {
|
|
|
|
seed := make([]byte, rand.Uint32()%1000)
|
2024-03-04 17:43:10 +00:00
|
|
|
//nolint:staticcheck
|
2022-03-24 14:15:43 +00:00
|
|
|
rand.Read(seed)
|
|
|
|
f.Add(seed)
|
|
|
|
}
|
|
|
|
|
|
|
|
f.Fuzz(func(t *testing.T, value []byte) {
|
|
|
|
m := new(Message)
|
|
|
|
r := io.NewBinReaderFromBuf(value)
|
|
|
|
require.NotPanics(t, func() { _ = m.Decode(r) })
|
|
|
|
})
|
|
|
|
}
|