Skip to content

Commit

Permalink
Merge pull request #3583 from ipfs/test/dat-serv/raw-links-unused
Browse files Browse the repository at this point in the history
test: add test for dag service doing short circuit for raw.Links()
  • Loading branch information
whyrusleeping authored Jan 10, 2017
2 parents 58975c3 + 4f2bc9f commit 4513732
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions merkledag/merkledag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"
"sync"
"testing"
"time"

blocks "github.com/ipfs/go-ipfs/blocks"
bserv "github.com/ipfs/go-ipfs/blockservice"
Expand Down Expand Up @@ -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")
}
}

0 comments on commit 4513732

Please sign in to comment.