test duplicate CIDs in getMany
License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>
Steven Allen committed
Mar 28, 2018 at 14:11 UTC
0f376b571814e1e14e4e41469a0253cbfcb39dcc
1 file changed
+30
merkledag/merkledag_test.go
+30
@@ -550,6 +550,36 @@ func TestCidRawDoesnNeedData(t *testing.T) {
550
}
551
}
552
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
+
583
func TestEnumerateAsyncFailsNotFound(t *testing.T) {
584
ctx := context.Background()
585