From 4f2bc9f81896f1ce9304aebef2cc327d328c659b Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Tue, 10 Jan 2017 17:12:21 +0100 Subject: [PATCH] test: add test for dag service doing short circuit for raw.Links() License: MIT Signed-off-by: Jakub Sztandera --- merkledag/merkledag_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/merkledag/merkledag_test.go b/merkledag/merkledag_test.go index 3fa45d8ac67..4f793eae81e 100644 --- a/merkledag/merkledag_test.go +++ b/merkledag/merkledag_test.go @@ -10,6 +10,7 @@ import ( "strings" "sync" "testing" + "time" blocks "github.com/ipfs/go-ipfs/blocks" bserv "github.com/ipfs/go-ipfs/blockservice" @@ -485,3 +486,21 @@ func TestCidRetention(t *testing.T) { t.Fatal("output cid didnt match") } } + +func TestCidRawDoesnNeedData(t *testing.T) { + srv := NewDAGService(dstest.Bserv()) + nd := NewRawNode([]byte("somedata")) + + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + + // there is no data for this node in the blockservice + // so dag service can't load it + links, err := srv.GetLinks(ctx, nd.Cid()) + if err != nil { + t.Fatal(err) + } + if len(links) != 0 { + t.Fatal("raw node shouldn't have any links") + } +}