add small test to fuzz cid creation routines
This commit is contained in:
10
cid_test.go
10
cid_test.go
@@ -2,6 +2,7 @@ package cid
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
mh "github.com/multiformats/go-multihash"
|
||||
@@ -108,3 +109,12 @@ func TestPrefixRoundtrip(t *testing.T) {
|
||||
t.Fatal("input prefix didnt match output")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFuzzCid(t *testing.T) {
|
||||
buf := make([]byte, 128)
|
||||
for i := 0; i < 200; i++ {
|
||||
s := rand.Intn(128)
|
||||
rand.Read(buf[:s])
|
||||
_, _ = Cast(buf[:s])
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user