From 8677934d48901e697845fabbb110fd8cc450725d Mon Sep 17 00:00:00 2001 From: Jeromy Date: Sun, 9 Oct 2016 12:19:14 -0700 Subject: [PATCH] add small test to fuzz cid creation routines --- cid_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cid_test.go b/cid_test.go index 209692d..20f5c88 100644 --- a/cid_test.go +++ b/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]) + } +}