Commit 25dc0003 authored by Masih H. Derkani's avatar Masih H. Derkani Committed by Daniel Martí

Use consistent import and bot CID versions in testing

Use both CID v0 and v1 in testing `ReadWrite` blockstore.

Use consistent import package name `merkledag` across tests.
parent dbdb7428
...@@ -10,7 +10,7 @@ import ( ...@@ -10,7 +10,7 @@ import (
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor" cbor "github.com/ipfs/go-ipld-cbor"
format "github.com/ipfs/go-ipld-format" format "github.com/ipfs/go-ipld-format"
dag "github.com/ipfs/go-merkledag" "github.com/ipfs/go-merkledag"
util "github.com/ipld/go-car/util" util "github.com/ipld/go-car/util"
) )
...@@ -58,7 +58,7 @@ func WriteCarWithWalker(ctx context.Context, ds format.NodeGetter, roots []cid.C ...@@ -58,7 +58,7 @@ func WriteCarWithWalker(ctx context.Context, ds format.NodeGetter, roots []cid.C
cw := &carWriter{ds: ds, w: w, walk: walk} cw := &carWriter{ds: ds, w: w, walk: walk}
seen := cid.NewSet() seen := cid.NewSet()
for _, r := range roots { for _, r := range roots {
if err := dag.Walk(ctx, cw.enumGetLinks, r, seen.Visit); err != nil { if err := merkledag.Walk(ctx, cw.enumGetLinks, r, seen.Visit); err != nil {
return err return err
} }
} }
......
...@@ -8,9 +8,9 @@ import ( ...@@ -8,9 +8,9 @@ import (
"strings" "strings"
"testing" "testing"
cid "github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
format "github.com/ipfs/go-ipld-format" format "github.com/ipfs/go-ipld-format"
dag "github.com/ipfs/go-merkledag" "github.com/ipfs/go-merkledag"
dstest "github.com/ipfs/go-merkledag/test" dstest "github.com/ipfs/go-merkledag/test"
basicnode "github.com/ipld/go-ipld-prime/node/basic" basicnode "github.com/ipld/go-ipld-prime/node/basic"
"github.com/ipld/go-ipld-prime/traversal/selector" "github.com/ipld/go-ipld-prime/traversal/selector"
...@@ -28,18 +28,18 @@ func assertAddNodes(t *testing.T, ds format.DAGService, nds ...format.Node) { ...@@ -28,18 +28,18 @@ func assertAddNodes(t *testing.T, ds format.DAGService, nds ...format.Node) {
func TestRoundtrip(t *testing.T) { func TestRoundtrip(t *testing.T) {
dserv := dstest.Mock() dserv := dstest.Mock()
a := dag.NewRawNode([]byte("aaaa")) a := merkledag.NewRawNode([]byte("aaaa"))
b := dag.NewRawNode([]byte("bbbb")) b := merkledag.NewRawNode([]byte("bbbb"))
c := dag.NewRawNode([]byte("cccc")) c := merkledag.NewRawNode([]byte("cccc"))
nd1 := &dag.ProtoNode{} nd1 := &merkledag.ProtoNode{}
nd1.AddNodeLink("cat", a) nd1.AddNodeLink("cat", a)
nd2 := &dag.ProtoNode{} nd2 := &merkledag.ProtoNode{}
nd2.AddNodeLink("first", nd1) nd2.AddNodeLink("first", nd1)
nd2.AddNodeLink("dog", b) nd2.AddNodeLink("dog", b)
nd3 := &dag.ProtoNode{} nd3 := &merkledag.ProtoNode{}
nd3.AddNodeLink("second", nd2) nd3.AddNodeLink("second", nd2)
nd3.AddNodeLink("bear", c) nd3.AddNodeLink("bear", c)
...@@ -80,20 +80,20 @@ func TestRoundtrip(t *testing.T) { ...@@ -80,20 +80,20 @@ func TestRoundtrip(t *testing.T) {
func TestRoundtripSelective(t *testing.T) { func TestRoundtripSelective(t *testing.T) {
sourceBserv := dstest.Bserv() sourceBserv := dstest.Bserv()
sourceBs := sourceBserv.Blockstore() sourceBs := sourceBserv.Blockstore()
dserv := dag.NewDAGService(sourceBserv) dserv := merkledag.NewDAGService(sourceBserv)
a := dag.NewRawNode([]byte("aaaa")) a := merkledag.NewRawNode([]byte("aaaa"))
b := dag.NewRawNode([]byte("bbbb")) b := merkledag.NewRawNode([]byte("bbbb"))
c := dag.NewRawNode([]byte("cccc")) c := merkledag.NewRawNode([]byte("cccc"))
nd1 := &dag.ProtoNode{} nd1 := &merkledag.ProtoNode{}
nd1.AddNodeLink("cat", a) nd1.AddNodeLink("cat", a)
nd2 := &dag.ProtoNode{} nd2 := &merkledag.ProtoNode{}
nd2.AddNodeLink("first", nd1) nd2.AddNodeLink("first", nd1)
nd2.AddNodeLink("dog", b) nd2.AddNodeLink("dog", b)
nd2.AddNodeLink("repeat", nd1) nd2.AddNodeLink("repeat", nd1)
nd3 := &dag.ProtoNode{} nd3 := &merkledag.ProtoNode{}
nd3.AddNodeLink("second", nd2) nd3.AddNodeLink("second", nd2)
nd3.AddNodeLink("bear", c) nd3.AddNodeLink("bear", c)
...@@ -106,7 +106,7 @@ func TestRoundtripSelective(t *testing.T) { ...@@ -106,7 +106,7 @@ func TestRoundtripSelective(t *testing.T) {
// this selector starts at n3, and traverses a link at index 1 (nd2, the second link, zero indexed) // this selector starts at n3, and traverses a link at index 1 (nd2, the second link, zero indexed)
// it then recursively traverses all of its children // it then recursively traverses all of its children
// the only node skipped is 'c' -- link at index 0 immediately below nd3 // the only node skipped is 'c' -- link at index 0 immediately below nd3
// the purpose is simply to show we are not writing the entire dag underneath // the purpose is simply to show we are not writing the entire merkledag underneath
// nd3 // nd3
selector := ssb.ExploreFields(func(efsb builder.ExploreFieldsSpecBuilder) { selector := ssb.ExploreFields(func(efsb builder.ExploreFieldsSpecBuilder) {
efsb.Insert("Links", efsb.Insert("Links",
......
...@@ -12,7 +12,7 @@ import ( ...@@ -12,7 +12,7 @@ import (
"testing" "testing"
"time" "time"
dag "github.com/ipfs/go-merkledag" "github.com/ipfs/go-merkledag"
carv2 "github.com/ipld/go-car/v2" carv2 "github.com/ipld/go-car/v2"
"github.com/ipld/go-car/v2/index" "github.com/ipld/go-car/v2/index"
...@@ -29,9 +29,9 @@ import ( ...@@ -29,9 +29,9 @@ import (
) )
var ( var (
rng = rand.New(rand.NewSource(1413)) rng = rand.New(rand.NewSource(1413))
oneTestBlock = dag.NewRawNode([]byte("fish")).Block oneTestBlockWithCidV1 = merkledag.NewRawNode([]byte("fish")).Block
anotherTestBlock = dag.NewRawNode([]byte("barreleye")).Block anotherTestBlockWithCidV0 = blocks.NewBlock([]byte("barreleye"))
) )
func TestBlockstore(t *testing.T) { func TestBlockstore(t *testing.T) {
...@@ -415,8 +415,8 @@ func TestBlockstoreResumptionIsSupportedOnFinalizedFile(t *testing.T) { ...@@ -415,8 +415,8 @@ func TestBlockstoreResumptionIsSupportedOnFinalizedFile(t *testing.T) {
} }
func TestReadWritePanicsOnlyWhenFinalized(t *testing.T) { func TestReadWritePanicsOnlyWhenFinalized(t *testing.T) {
oneTestBlockCid := oneTestBlock.Cid() oneTestBlockCid := oneTestBlockWithCidV1.Cid()
anotherTestBlockCid := anotherTestBlock.Cid() anotherTestBlockCid := anotherTestBlockWithCidV0.Cid()
wantRoots := []cid.Cid{oneTestBlockCid, anotherTestBlockCid} wantRoots := []cid.Cid{oneTestBlockCid, anotherTestBlockCid}
path := filepath.Join(t.TempDir(), "readwrite-finalized-panic.car") path := filepath.Join(t.TempDir(), "readwrite-finalized-panic.car")
...@@ -424,16 +424,16 @@ func TestReadWritePanicsOnlyWhenFinalized(t *testing.T) { ...@@ -424,16 +424,16 @@ func TestReadWritePanicsOnlyWhenFinalized(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
t.Cleanup(func() { subject.Close() }) t.Cleanup(func() { subject.Close() })
require.NoError(t, subject.Put(oneTestBlock)) require.NoError(t, subject.Put(oneTestBlockWithCidV1))
require.NoError(t, subject.Put(anotherTestBlock)) require.NoError(t, subject.Put(anotherTestBlockWithCidV0))
gotBlock, err := subject.Get(oneTestBlockCid) gotBlock, err := subject.Get(oneTestBlockCid)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, oneTestBlock, gotBlock) require.Equal(t, oneTestBlockWithCidV1, gotBlock)
gotSize, err := subject.GetSize(oneTestBlockCid) gotSize, err := subject.GetSize(oneTestBlockCid)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, len(oneTestBlock.RawData()), gotSize) require.Equal(t, len(oneTestBlockWithCidV1.RawData()), gotSize)
gotRoots, err := subject.Roots() gotRoots, err := subject.Roots()
require.NoError(t, err) require.NoError(t, err)
...@@ -452,15 +452,15 @@ func TestReadWritePanicsOnlyWhenFinalized(t *testing.T) { ...@@ -452,15 +452,15 @@ func TestReadWritePanicsOnlyWhenFinalized(t *testing.T) {
require.Panics(t, func() { subject.GetSize(anotherTestBlockCid) }) require.Panics(t, func() { subject.GetSize(anotherTestBlockCid) })
require.Panics(t, func() { subject.Has(anotherTestBlockCid) }) require.Panics(t, func() { subject.Has(anotherTestBlockCid) })
require.Panics(t, func() { subject.HashOnRead(true) }) require.Panics(t, func() { subject.HashOnRead(true) })
require.Panics(t, func() { subject.Put(oneTestBlock) }) require.Panics(t, func() { subject.Put(oneTestBlockWithCidV1) })
require.Panics(t, func() { subject.PutMany([]blocks.Block{anotherTestBlock}) }) require.Panics(t, func() { subject.PutMany([]blocks.Block{anotherTestBlockWithCidV0}) })
require.Panics(t, func() { subject.AllKeysChan(context.Background()) }) require.Panics(t, func() { subject.AllKeysChan(context.Background()) })
require.Panics(t, func() { subject.DeleteBlock(oneTestBlockCid) }) require.Panics(t, func() { subject.DeleteBlock(oneTestBlockCid) })
} }
func TestReadWriteWithPaddingWorksAsExpected(t *testing.T) { func TestReadWriteWithPaddingWorksAsExpected(t *testing.T) {
oneTestBlockCid := oneTestBlock.Cid() oneTestBlockCid := oneTestBlockWithCidV1.Cid()
anotherTestBlockCid := anotherTestBlock.Cid() anotherTestBlockCid := anotherTestBlockWithCidV0.Cid()
WantRoots := []cid.Cid{oneTestBlockCid, anotherTestBlockCid} WantRoots := []cid.Cid{oneTestBlockCid, anotherTestBlockCid}
path := filepath.Join(t.TempDir(), "readwrite-with-padding.car") path := filepath.Join(t.TempDir(), "readwrite-with-padding.car")
...@@ -473,8 +473,8 @@ func TestReadWriteWithPaddingWorksAsExpected(t *testing.T) { ...@@ -473,8 +473,8 @@ func TestReadWriteWithPaddingWorksAsExpected(t *testing.T) {
blockstore.WithIndexPadding(wantIndexPadding)) blockstore.WithIndexPadding(wantIndexPadding))
require.NoError(t, err) require.NoError(t, err)
t.Cleanup(func() { subject.Close() }) t.Cleanup(func() { subject.Close() })
require.NoError(t, subject.Put(oneTestBlock)) require.NoError(t, subject.Put(oneTestBlockWithCidV1))
require.NoError(t, subject.Put(anotherTestBlock)) require.NoError(t, subject.Put(anotherTestBlockWithCidV0))
require.NoError(t, subject.Finalize()) require.NoError(t, subject.Finalize())
// Assert CARv2 header contains right offsets. // Assert CARv2 header contains right offsets.
...@@ -497,10 +497,10 @@ func TestReadWriteWithPaddingWorksAsExpected(t *testing.T) { ...@@ -497,10 +497,10 @@ func TestReadWriteWithPaddingWorksAsExpected(t *testing.T) {
require.Equal(t, WantRoots, gotCarV1.Header.Roots) require.Equal(t, WantRoots, gotCarV1.Header.Roots)
gotOneBlock, err := gotCarV1.Next() gotOneBlock, err := gotCarV1.Next()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, oneTestBlock, gotOneBlock) require.Equal(t, oneTestBlockWithCidV1, gotOneBlock)
gotAnotherBlock, err := gotCarV1.Next() gotAnotherBlock, err := gotCarV1.Next()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, anotherTestBlock, gotAnotherBlock) require.Equal(t, anotherTestBlockWithCidV0, gotAnotherBlock)
_, err = gotCarV1.Next() _, err = gotCarV1.Next()
require.Equal(t, io.EOF, err) require.Equal(t, io.EOF, err)
...@@ -523,7 +523,7 @@ func TestReadWriteResumptionFromNonV2FileIsError(t *testing.T) { ...@@ -523,7 +523,7 @@ func TestReadWriteResumptionFromNonV2FileIsError(t *testing.T) {
} }
func TestReadWriteResumptionFromFileWithDifferentCarV1PaddingIsError(t *testing.T) { func TestReadWriteResumptionFromFileWithDifferentCarV1PaddingIsError(t *testing.T) {
oneTestBlockCid := oneTestBlock.Cid() oneTestBlockCid := oneTestBlockWithCidV1.Cid()
WantRoots := []cid.Cid{oneTestBlockCid} WantRoots := []cid.Cid{oneTestBlockCid}
path := filepath.Join(t.TempDir(), "readwrite-resume-with-padding.car") path := filepath.Join(t.TempDir(), "readwrite-resume-with-padding.car")
...@@ -533,7 +533,7 @@ func TestReadWriteResumptionFromFileWithDifferentCarV1PaddingIsError(t *testing. ...@@ -533,7 +533,7 @@ func TestReadWriteResumptionFromFileWithDifferentCarV1PaddingIsError(t *testing.
blockstore.WithCarV1Padding(1413)) blockstore.WithCarV1Padding(1413))
require.NoError(t, err) require.NoError(t, err)
t.Cleanup(func() { subject.Close() }) t.Cleanup(func() { subject.Close() })
require.NoError(t, subject.Put(oneTestBlock)) require.NoError(t, subject.Put(oneTestBlockWithCidV1))
require.NoError(t, subject.Finalize()) require.NoError(t, subject.Finalize())
resumingSubject, err := blockstore.OpenReadWrite( resumingSubject, err := blockstore.OpenReadWrite(
......
...@@ -9,6 +9,7 @@ require ( ...@@ -9,6 +9,7 @@ require (
github.com/ipfs/go-ipld-cbor v0.0.5 github.com/ipfs/go-ipld-cbor v0.0.5
github.com/ipfs/go-ipld-format v0.2.0 github.com/ipfs/go-ipld-format v0.2.0
github.com/ipfs/go-merkledag v0.3.2 github.com/ipfs/go-merkledag v0.3.2
github.com/klauspost/cpuid/v2 v2.0.8 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect github.com/mattn/go-colorable v0.1.8 // indirect
github.com/multiformats/go-multicodec v0.2.1-0.20210713081508-b421db6850ae github.com/multiformats/go-multicodec v0.2.1-0.20210713081508-b421db6850ae
github.com/multiformats/go-multihash v0.0.15 github.com/multiformats/go-multihash v0.0.15
...@@ -16,6 +17,7 @@ require ( ...@@ -16,6 +17,7 @@ require (
github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9 github.com/petar/GoLLRB v0.0.0-20210522233825-ae3b015fd3e9
github.com/stretchr/testify v1.7.0 github.com/stretchr/testify v1.7.0
github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11 github.com/whyrusleeping/cbor v0.0.0-20171005072247-63513f603b11
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
golang.org/x/exp v0.0.0-20210615023648-acb5c1269671 golang.org/x/exp v0.0.0-20210615023648-acb5c1269671
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 // indirect golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
) )
...@@ -256,8 +256,9 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW ...@@ -256,8 +256,9 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/klauspost/cpuid/v2 v2.0.4 h1:g0I61F2K2DjRHz1cnxlkNSBIaePVoJIjjnHui8QHbiw=
github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.0.8 h1:bhR2mgIlno/Sfk4oUbH4sPlc83z1yGrN9bvqiq3C33I=
github.com/klauspost/cpuid/v2 v2.0.8/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/koron/go-ssdp v0.0.0-20180514024734-4a0ed625a78b h1:wxtKgYHEncAU00muMD06dzLiahtGM1eouRNOzVV7tdQ= github.com/koron/go-ssdp v0.0.0-20180514024734-4a0ed625a78b h1:wxtKgYHEncAU00muMD06dzLiahtGM1eouRNOzVV7tdQ=
github.com/koron/go-ssdp v0.0.0-20180514024734-4a0ed625a78b/go.mod h1:5Ky9EC2xfoUKUor0Hjgi2BJhCSXJfMOFlmyYrVKGQMk= github.com/koron/go-ssdp v0.0.0-20180514024734-4a0ed625a78b/go.mod h1:5Ky9EC2xfoUKUor0Hjgi2BJhCSXJfMOFlmyYrVKGQMk=
...@@ -570,8 +571,9 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U ...@@ -570,8 +571,9 @@ golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf h1:B2n+Zi5QeYRDAEodEu72OS36gmTWjgpXr2+cWcBW90o=
golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= golang.org/x/crypto v0.0.0-20210506145944-38f3c27a63bf/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 h1:/UOmuWzQfxxo9UtlXMwuQU8CMgg1eZXqTRwkSQJWKOI=
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4= golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4=
golang.org/x/exp v0.0.0-20210615023648-acb5c1269671 h1:ddvpKwqE7dm58PoWjRCmaCiA3DANEW0zWGfNYQD212Y= golang.org/x/exp v0.0.0-20210615023648-acb5c1269671 h1:ddvpKwqE7dm58PoWjRCmaCiA3DANEW0zWGfNYQD212Y=
...@@ -648,8 +650,9 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w ...@@ -648,8 +650,9 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 h1:F5Gozwx4I1xtr/sr/8CFbb57iKi3297KFs0QDbGN60A= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
......
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
cbor "github.com/ipfs/go-ipld-cbor" cbor "github.com/ipfs/go-ipld-cbor"
format "github.com/ipfs/go-ipld-format" format "github.com/ipfs/go-ipld-format"
dag "github.com/ipfs/go-merkledag" "github.com/ipfs/go-merkledag"
) )
func init() { func init() {
...@@ -49,7 +49,7 @@ func WriteCar(ctx context.Context, ds format.NodeGetter, roots []cid.Cid, w io.W ...@@ -49,7 +49,7 @@ func WriteCar(ctx context.Context, ds format.NodeGetter, roots []cid.Cid, w io.W
cw := &carWriter{ds: ds, w: w} cw := &carWriter{ds: ds, w: w}
seen := cid.NewSet() seen := cid.NewSet()
for _, r := range roots { for _, r := range roots {
if err := dag.Walk(ctx, cw.enumGetLinks, r, seen.Visit); err != nil { if err := merkledag.Walk(ctx, cw.enumGetLinks, r, seen.Visit); err != nil {
return err return err
} }
} }
......
...@@ -12,7 +12,7 @@ import ( ...@@ -12,7 +12,7 @@ import (
cid "github.com/ipfs/go-cid" cid "github.com/ipfs/go-cid"
format "github.com/ipfs/go-ipld-format" format "github.com/ipfs/go-ipld-format"
dag "github.com/ipfs/go-merkledag" "github.com/ipfs/go-merkledag"
dstest "github.com/ipfs/go-merkledag/test" dstest "github.com/ipfs/go-merkledag/test"
) )
...@@ -26,18 +26,18 @@ func assertAddNodes(t *testing.T, ds format.DAGService, nds ...format.Node) { ...@@ -26,18 +26,18 @@ func assertAddNodes(t *testing.T, ds format.DAGService, nds ...format.Node) {
func TestRoundtrip(t *testing.T) { func TestRoundtrip(t *testing.T) {
dserv := dstest.Mock() dserv := dstest.Mock()
a := dag.NewRawNode([]byte("aaaa")) a := merkledag.NewRawNode([]byte("aaaa"))
b := dag.NewRawNode([]byte("bbbb")) b := merkledag.NewRawNode([]byte("bbbb"))
c := dag.NewRawNode([]byte("cccc")) c := merkledag.NewRawNode([]byte("cccc"))
nd1 := &dag.ProtoNode{} nd1 := &merkledag.ProtoNode{}
nd1.AddNodeLink("cat", a) nd1.AddNodeLink("cat", a)
nd2 := &dag.ProtoNode{} nd2 := &merkledag.ProtoNode{}
nd2.AddNodeLink("first", nd1) nd2.AddNodeLink("first", nd1)
nd2.AddNodeLink("dog", b) nd2.AddNodeLink("dog", b)
nd3 := &dag.ProtoNode{} nd3 := &merkledag.ProtoNode{}
nd3.AddNodeLink("second", nd2) nd3.AddNodeLink("second", nd2)
nd3.AddNodeLink("bear", c) nd3.AddNodeLink("bear", c)
...@@ -233,8 +233,8 @@ func TestBadHeaders(t *testing.T) { ...@@ -233,8 +233,8 @@ func TestBadHeaders(t *testing.T) {
} }
func TestCarHeaderMatchess(t *testing.T) { func TestCarHeaderMatchess(t *testing.T) {
oneCid := dag.NewRawNode([]byte("fish")).Cid() oneCid := merkledag.NewRawNode([]byte("fish")).Cid()
anotherCid := dag.NewRawNode([]byte("lobster")).Cid() anotherCid := merkledag.NewRawNode([]byte("lobster")).Cid()
tests := []struct { tests := []struct {
name string name string
one CarHeader one CarHeader
......
...@@ -7,7 +7,7 @@ import ( ...@@ -7,7 +7,7 @@ import (
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
format "github.com/ipfs/go-ipld-format" format "github.com/ipfs/go-ipld-format"
dag "github.com/ipfs/go-merkledag" "github.com/ipfs/go-merkledag"
dstest "github.com/ipfs/go-merkledag/test" dstest "github.com/ipfs/go-merkledag/test"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
...@@ -66,25 +66,25 @@ func TestNewWriter(t *testing.T) { ...@@ -66,25 +66,25 @@ func TestNewWriter(t *testing.T) {
func generateRootCid(t *testing.T, adder format.NodeAdder) []cid.Cid { func generateRootCid(t *testing.T, adder format.NodeAdder) []cid.Cid {
// TODO convert this into a utility testing lib that takes an rng and generates a random DAG with some threshold for depth/breadth. // TODO convert this into a utility testing lib that takes an rng and generates a random DAG with some threshold for depth/breadth.
this := dag.NewRawNode([]byte("fish")) this := merkledag.NewRawNode([]byte("fish"))
that := dag.NewRawNode([]byte("lobster")) that := merkledag.NewRawNode([]byte("lobster"))
other := dag.NewRawNode([]byte("🌊")) other := merkledag.NewRawNode([]byte("🌊"))
one := &dag.ProtoNode{} one := &merkledag.ProtoNode{}
assertAddNodeLink(t, one, this, "fishmonger") assertAddNodeLink(t, one, this, "fishmonger")
another := &dag.ProtoNode{} another := &merkledag.ProtoNode{}
assertAddNodeLink(t, another, one, "barreleye") assertAddNodeLink(t, another, one, "barreleye")
assertAddNodeLink(t, another, that, "🐡") assertAddNodeLink(t, another, that, "🐡")
andAnother := &dag.ProtoNode{} andAnother := &merkledag.ProtoNode{}
assertAddNodeLink(t, andAnother, another, "🍤") assertAddNodeLink(t, andAnother, another, "🍤")
assertAddNodes(t, adder, this, that, other, one, another, andAnother) assertAddNodes(t, adder, this, that, other, one, another, andAnother)
return []cid.Cid{andAnother.Cid()} return []cid.Cid{andAnother.Cid()}
} }
func assertAddNodeLink(t *testing.T, pn *dag.ProtoNode, fn format.Node, name string) { func assertAddNodeLink(t *testing.T, pn *merkledag.ProtoNode, fn format.Node, name string) {
assert.NoError(t, pn.AddNodeLink(name, fn)) assert.NoError(t, pn.AddNodeLink(name, fn))
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment