Skip to content

Commit

Permalink
test: test parsing non-sha256 hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Dec 3, 2019
1 parent 60ab0f8 commit 5df8995
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cid_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}

0 comments on commit 5df8995

Please # to comment.