Skip to content

Commit 5df8995

Browse files
committed
test: test parsing non-sha256 hashes
1 parent 60ab0f8 commit 5df8995

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

cid_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,3 +584,14 @@ func TestReadCidsFromBuffer(t *testing.T) {
584584
t.Fatal("had trailing bytes")
585585
}
586586
}
587+
588+
func TestBadParse(t *testing.T) {
589+
hash, err := mh.Sum([]byte("foobar"), mh.SHA3_256, -1)
590+
if err != nil {
591+
t.Fatal(err)
592+
}
593+
_, err = Parse(hash)
594+
if err == nil {
595+
t.Fatal("expected to fail to parse an invalid CIDv1 CID")
596+
}
597+
}

0 commit comments

Comments
 (0)