Skip to content

Commit 1a9f048

Browse files
authoredAug 9, 2018
Merge pull request ipfs/go-unixfs#6 from ipfs/feat/protobuf
update gogo protobuf This commit was moved from ipfs/go-unixfs@08716b9
2 parents d77bf9d + 3ece1ca commit 1a9f048

File tree

2 files changed

+121
-22
lines changed

2 files changed

+121
-22
lines changed
 

‎unixfs/ipld-merkledag/importer/importer_test.go

+36-1
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import (
77
"io/ioutil"
88
"testing"
99

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

12+
cid "github.com/ipfs/go-cid"
1313
chunker "github.com/ipfs/go-ipfs-chunker"
1414
u "github.com/ipfs/go-ipfs-util"
1515
ipld "github.com/ipfs/go-ipld-format"
16+
mdtest "github.com/ipfs/go-merkledag/test"
1617
)
1718

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

39+
func TestStableCid(t *testing.T) {
40+
ds := mdtest.Mock()
41+
buf := make([]byte, 10 * 1024 * 1024)
42+
u.NewSeededRand(0xdeadbeef).Read(buf)
43+
r := bytes.NewReader(buf)
44+
45+
nd, err := BuildDagFromReader(ds, chunker.DefaultSplitter(r))
46+
if err != nil {
47+
t.Fatal(err)
48+
}
49+
50+
expected, err := cid.Decode("QmZN1qquw84zhV4j6vT56tCcmFxaDaySL1ezTXFvMdNmrK")
51+
if err != nil {
52+
t.Fatal(err)
53+
}
54+
if !expected.Equals(nd.Cid()) {
55+
t.Fatalf("expected CID %s, got CID %s", expected, nd)
56+
}
57+
58+
dr, err := uio.NewDagReader(context.Background(), nd, ds)
59+
if err != nil {
60+
t.Fatal(err)
61+
}
62+
63+
out, err := ioutil.ReadAll(dr)
64+
if err != nil {
65+
t.Fatal(err)
66+
}
67+
68+
if !bytes.Equal(out, buf) {
69+
t.Fatal("bad read")
70+
}
71+
}
72+
3873
func TestBalancedDag(t *testing.T) {
3974
ds := mdtest.Mock()
4075
buf := make([]byte, 10000)

‎unixfs/ipld-merkledag/pb/unixfs.pb.go

+85-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.