Add unit test for unexpected eof

This commit is contained in:
gammazero
2023-04-03 08:18:57 -07:00
committed by Rod Vagg
parent 0981f8566c
commit 83a0e939a4
2 changed files with 13 additions and 0 deletions

View File

@@ -795,6 +795,16 @@ func TestFromReaderNoData(t *testing.T) {
if n != 0 {
t.Fatal("Expected 0 data")
}
// Read byte indicatiing more data to and check error is ErrInvalidCid.
_, _, err = CidFromReader(bytes.NewReader([]byte{0x80}))
if !errors.Is(err, ErrInvalidCid{}) {
t.Fatal("Expected ErrInvalidCid error")
}
// Check for expected wrapped error.
if !errors.Is(err, io.ErrUnexpectedEOF) {
t.Fatal("Expected error", io.ErrUnexpectedEOF)
}
}
func TestBadParse(t *testing.T) {