Skip to content

Commit

Permalink
Merge pull request ipfs/go-unixfs#6 from ipfs/feat/protobuf
Browse files Browse the repository at this point in the history
update gogo protobuf

This commit was moved from ipfs/go-unixfs@08716b9
  • Loading branch information
Stebalien authored Aug 9, 2018
2 parents d77bf9d + 3ece1ca commit 1a9f048
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 22 deletions.
37 changes: 36 additions & 1 deletion unixfs/ipld-merkledag/importer/importer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import (
"io/ioutil"
"testing"

mdtest "github.com/ipfs/go-merkledag/test"
uio "github.com/ipfs/go-unixfs/io"

cid "github.com/ipfs/go-cid"
chunker "github.com/ipfs/go-ipfs-chunker"
u "github.com/ipfs/go-ipfs-util"
ipld "github.com/ipfs/go-ipld-format"
mdtest "github.com/ipfs/go-merkledag/test"
)

func getBalancedDag(t testing.TB, size int64, blksize int64) (ipld.Node, ipld.DAGService) {
Expand All @@ -35,6 +36,40 @@ func getTrickleDag(t testing.TB, size int64, blksize int64) (ipld.Node, ipld.DAG
return nd, ds
}

func TestStableCid(t *testing.T) {
ds := mdtest.Mock()
buf := make([]byte, 10 * 1024 * 1024)
u.NewSeededRand(0xdeadbeef).Read(buf)
r := bytes.NewReader(buf)

nd, err := BuildDagFromReader(ds, chunker.DefaultSplitter(r))
if err != nil {
t.Fatal(err)
}

expected, err := cid.Decode("QmZN1qquw84zhV4j6vT56tCcmFxaDaySL1ezTXFvMdNmrK")
if err != nil {
t.Fatal(err)
}
if !expected.Equals(nd.Cid()) {
t.Fatalf("expected CID %s, got CID %s", expected, nd)
}

dr, err := uio.NewDagReader(context.Background(), nd, ds)
if err != nil {
t.Fatal(err)
}

out, err := ioutil.ReadAll(dr)
if err != nil {
t.Fatal(err)
}

if !bytes.Equal(out, buf) {
t.Fatal("bad read")
}
}

func TestBalancedDag(t *testing.T) {
ds := mdtest.Mock()
buf := make([]byte, 10000)
Expand Down
106 changes: 85 additions & 21 deletions unixfs/ipld-merkledag/pb/unixfs.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1a9f048

Please # to comment.