test: add test for dag service doing short circuit for raw.Links()
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
Jakub Sztandera committed
Jan 10, 2017 at 17:12 UTC
4f2bc9f81896f1ce9304aebef2cc327d328c659b
1 file changed
+19
merkledag/merkledag_test.go
+19
@@ -10,6 +10,7 @@ import (
10
"strings"
11
"sync"
12
"testing"
13
+ "time"
14
15
blocks "github.com/ipfs/go-ipfs/blocks"
16
bserv "github.com/ipfs/go-ipfs/blockservice"
@@ -485,3 +486,21 @@ func TestCidRetention(t *testing.T) {
486
t.Fatal("output cid didnt match")
487
}
488
}
489
+
490
+func TestCidRawDoesnNeedData(t *testing.T) {
491
+ srv := NewDAGService(dstest.Bserv())
492
+ nd := NewRawNode([]byte("somedata"))
493
+
494
+ ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
495
+ defer cancel()
496
+
497
+ // there is no data for this node in the blockservice
498
+ // so dag service can't load it
499
+ links, err := srv.GetLinks(ctx, nd.Cid())
500
+ if err != nil {
501
+ t.Fatal(err)
502
+ }
503
+ if len(links) != 0 {
504
+ t.Fatal("raw node shouldn't have any links")
505
+ }
506
+}