Skip to content

Commit 7d5c56b

Browse files
committed
test duplicate CIDs in getMany
License: MIT Signed-off-by: Steven Allen <[email protected]>
1 parent 17f4c17 commit 7d5c56b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

merkledag_test.go

+30
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,36 @@ func TestCidRawDoesnNeedData(t *testing.T) {
550550
}
551551
}
552552

553+
func TestGetManyDuplicate(t *testing.T) {
554+
ctx := context.Background()
555+
556+
srv := NewDAGService(dstest.Bserv())
557+
558+
nd := NodeWithData([]byte("foo"))
559+
if err := srv.Add(ctx, nd); err != nil {
560+
t.Fatal(err)
561+
}
562+
nds := srv.GetMany(ctx, []*cid.Cid{nd.Cid(), nd.Cid(), nd.Cid()})
563+
out, ok := <-nds
564+
if !ok {
565+
t.Fatal("expecting node foo")
566+
}
567+
if out.Err != nil {
568+
t.Fatal(out.Err)
569+
}
570+
if !out.Node.Cid().Equals(nd.Cid()) {
571+
t.Fatal("got wrong node")
572+
}
573+
out, ok = <-nds
574+
if ok {
575+
if out.Err != nil {
576+
t.Fatal(out.Err)
577+
} else {
578+
t.Fatal("expecting no more nodes")
579+
}
580+
}
581+
}
582+
553583
func TestEnumerateAsyncFailsNotFound(t *testing.T) {
554584
ctx := context.Background()
555585

0 commit comments

Comments
 (0)