2022-03-24 14:15:43 +00:00
|
|
|
package network
|
|
|
|
|
|
|
|
import (
|
2024-08-30 12:48:13 +00:00
|
|
|
"math/rand/v2"
|
2022-03-24 14:15:43 +00:00
|
|
|
"testing"
|
|
|
|
|
2024-08-30 12:48:13 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/internal/random"
|
2022-03-24 14:15:43 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/io"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func FuzzMessageDecode(f *testing.F) {
|
2024-08-30 18:41:02 +00:00
|
|
|
for range 100 {
|
2024-08-30 12:48:13 +00:00
|
|
|
seed := make([]byte, rand.IntN(1000))
|
|
|
|
random.Fill(seed)
|
2022-03-24 14:15:43 +00:00
|
|
|
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) })
|
|
|
|
})
|
|
|
|
}
|