mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-05 16:28:06 +08:00
test: add invialid protobuf data testcase to dagreader
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
parent
8ccaf5bbfa
commit
b699e71c0b
@ -131,7 +131,7 @@ func (dr *DagReader) precalcNextBuf(ctx context.Context) error {
|
||||
dr.buf = NewRSNCFromBytes(pb.GetData())
|
||||
return nil
|
||||
case ftpb.Data_Metadata:
|
||||
return errors.New("Shouldnt have had metadata object inside file")
|
||||
return errors.New("shouldnt have had metadata object inside file")
|
||||
case ftpb.Data_Symlink:
|
||||
return errors.New("shouldnt have had symlink inside file")
|
||||
default:
|
||||
|
||||
@ -144,6 +144,19 @@ func TestTypeFailures(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestBadPBData(t *testing.T) {
|
||||
dserv := testu.GetDAGServ()
|
||||
ctx, closer := context.WithCancel(context.Background())
|
||||
defer closer()
|
||||
|
||||
node := mdag.NodeWithData([]byte{42})
|
||||
_, err := NewDagReader(ctx, node, dserv)
|
||||
if err == nil {
|
||||
t.Fatal("excepted error, got nil")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func readByte(t testing.TB, reader *DagReader) byte {
|
||||
out := make([]byte, 1)
|
||||
c, err := reader.Read(out)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user