test: test parsing non-sha256 hashes

This commit is contained in:
Steven Allen
2019-12-02 20:41:59 -05:00
parent 60ab0f84f0
commit 5df89959a0

View File

@@ -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")
}
}