From 5df89959a068ade9f6c019467a5c3823122ed396 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Mon, 2 Dec 2019 20:41:59 -0500 Subject: [PATCH] test: test parsing non-sha256 hashes --- cid_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cid_test.go b/cid_test.go index 5d07497..9d0f9a1 100644 --- a/cid_test.go +++ b/cid_test.go @@ -584,3 +584,14 @@ func TestReadCidsFromBuffer(t *testing.T) { t.Fatal("had trailing bytes") } } + +func TestBadParse(t *testing.T) { + hash, err := mh.Sum([]byte("foobar"), mh.SHA3_256, -1) + if err != nil { + t.Fatal(err) + } + _, err = Parse(hash) + if err == nil { + t.Fatal("expected to fail to parse an invalid CIDv1 CID") + } +}