diff --git a/hamt/hamt_test.go b/hamt/hamt_test.go index 8d0b93889..90377c2b1 100644 --- a/hamt/hamt_test.go +++ b/hamt/hamt_test.go @@ -162,7 +162,7 @@ func TestDirBuilding(t *testing.T) { k := nd.Cid() - if k.String() != "QmY89TkSEVHykWMHDmyejSWFj9CYNtvzw4UwnT9xbc4Zjc" { + if k.String() != "QmWd277BEJs7VKLpd6Ki6mC12ESnKcFQAqF5JDJW4TpUjY" { t.Fatalf("output didnt match what we expected (got %s)", k.String()) } } diff --git a/io/dagreader_test.go b/io/dagreader_test.go index de664370c..8a4d36f4a 100644 --- a/io/dagreader_test.go +++ b/io/dagreader_test.go @@ -204,7 +204,7 @@ func TestTypeFailures(t *testing.T) { if err != nil { t.Fatal(err) } - node = mdag.NodeWithData(data) + node = unixfs.ProtoNodeCIDv1WithData(data) if _, err := NewDagReader(ctx, node, dserv); err != ErrCantReadSymlinks { t.Fatalf("excepted to get %v, got %v", ErrCantReadSymlinks, err) @@ -216,7 +216,7 @@ func TestBadPBData(t *testing.T) { ctx, closer := context.WithCancel(context.Background()) defer closer() - node := mdag.NodeWithData([]byte{42}) + node := unixfs.ProtoNodeCIDv1WithData([]byte{42}) _, err := NewDagReader(ctx, node, dserv) if err == nil { t.Fatal("excepted error, got nil") @@ -241,7 +241,7 @@ func TestMetadataNode(t *testing.T) { if err != nil { t.Fatal(err) } - node := mdag.NodeWithData(data) + node := unixfs.ProtoNodeCIDv1WithData(data) _, err = NewDagReader(ctx, node, dserv) if err == nil { diff --git a/io/directory_test.go b/io/directory_test.go index ca67f5d25..6e3a5ea9d 100644 --- a/io/directory_test.go +++ b/io/directory_test.go @@ -222,12 +222,12 @@ func TestProductionLinkSize(t *testing.T) { link, err := ipld.MakeLink(ft.EmptyDirNode()) assert.NoError(t, err) link.Name = "directory_link_name" - assert.Equal(t, 53, productionLinkSize(link.Name, link.Cid)) + assert.Equal(t, 55, productionLinkSize(link.Name, link.Cid)) link, err = ipld.MakeLink(ft.EmptyFileNode()) assert.NoError(t, err) link.Name = "file_link_name" - assert.Equal(t, 48, productionLinkSize(link.Name, link.Cid)) + assert.Equal(t, 50, productionLinkSize(link.Name, link.Cid)) ds := mdtest.Mock() basicDir := newEmptyBasicDirectory(ds) @@ -240,7 +240,7 @@ func TestProductionLinkSize(t *testing.T) { link, err = ipld.MakeLink(basicDirNode) assert.NoError(t, err) link.Name = "basic_dir" - assert.Equal(t, 43, productionLinkSize(link.Name, link.Cid)) + assert.Equal(t, 45, productionLinkSize(link.Name, link.Cid)) } // Test HAMTDirectory <-> BasicDirectory switch based on directory size. The diff --git a/mod/dagmodifier_test.go b/mod/dagmodifier_test.go index 9870b2022..b07b1cc98 100644 --- a/mod/dagmodifier_test.go +++ b/mod/dagmodifier_test.go @@ -7,7 +7,6 @@ import ( "io/ioutil" "testing" - dag "github.com/ipfs/go-merkledag" h "github.com/ipfs/go-unixfs/importer/helpers" trickle "github.com/ipfs/go-unixfs/importer/trickle" uio "github.com/ipfs/go-unixfs/io" @@ -416,7 +415,7 @@ func testDagTruncate(t *testing.T, opts testu.NodeOpts) { // if offset > curNode's size. func TestDagSync(t *testing.T) { dserv := testu.GetDAGServ() - nd := dag.NodeWithData(unixfs.FilePBData(nil, 0)) + nd := unixfs.ProtoNodeCIDv1WithData(unixfs.FilePBData(nil, 0)) ctx, cancel := context.WithCancel(context.Background()) defer cancel() diff --git a/unixfs.go b/unixfs.go index 026b8bb3f..2e61754aa 100644 --- a/unixfs.go +++ b/unixfs.go @@ -356,14 +356,24 @@ func BytesForMetadata(m *Metadata) ([]byte, error) { return proto.Marshal(pbd) } +// ProtoNodeCIDv1WithData returns a ProtoNode with the given data and CIDv1. +// FIXME: Switch to CIDv1 here until we decide if the switch should happen +// in `go-merkledag` itself (see https://github.com/ipfs/go-merkledag/issues/86). +func ProtoNodeCIDv1WithData(data []byte) *dag.ProtoNode { + n := &dag.ProtoNode{} + n.SetData(data) + n.SetCidBuilder(dag.V1CidPrefix()) + return n +} + // EmptyDirNode creates an empty folder Protonode. func EmptyDirNode() *dag.ProtoNode { - return dag.NodeWithData(FolderPBData()) + return ProtoNodeCIDv1WithData(FolderPBData()) } // EmptyFileNode creates an empty file Protonode. func EmptyFileNode() *dag.ProtoNode { - return dag.NodeWithData(FilePBData(nil, 0)) + return ProtoNodeCIDv1WithData(FilePBData(nil, 0)) } // ReadUnixFSNodeData extracts the UnixFS data from an IPLD node. diff --git a/version.json b/version.json index 9ed87d762..372b6eab3 100644 --- a/version.json +++ b/version.json @@ -1,3 +1,3 @@ { - "version": "v0.3.1" + "version": "v0.4.0" }