Skip to content

Commit 47f3230

Browse files
authored
Merge pull request ipfs/go-merkledag#4 from ipfs/fix/upgrade-protobuf
update gogo protobuf This commit was moved from ipfs/go-merkledag@64bc844
2 parents b56f793 + 4b25725 commit 47f3230

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

ipld/merkledag/coding.go

+5
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import (
1313
ipld "github.com/ipfs/go-ipld-format"
1414
)
1515

16+
// Make sure the user doesn't upgrade this file.
17+
// We need to check *here* as well as inside the `pb` package *just* in case the
18+
// user replaces *all* go files in that package.
19+
const _ = pb.DoNotUpgradeFileEverItWillChangeYourHashes
20+
1621
// for now, we use a PBNode intermediate thing.
1722
// because native go objects are nice.
1823

ipld/merkledag/node_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,26 @@ import (
99
mdtest "github.com/ipfs/go-merkledag/test"
1010

1111
ipld "github.com/ipfs/go-ipld-format"
12+
cid "github.com/ipfs/go-cid"
1213
)
1314

15+
func TestStableCID(t *testing.T) {
16+
nd := &ProtoNode{}
17+
nd.SetData([]byte("foobar"))
18+
nd.SetLinks([]*ipld.Link{
19+
{Name: "a"},
20+
{Name: "b"},
21+
{Name: "c"},
22+
})
23+
expected, err := cid.Decode("QmSN3WED2xPLbYvBbfvew2ZLtui8EbFYYcbfkpKH5jwG9C")
24+
if err != nil {
25+
t.Fatal(err)
26+
}
27+
if !nd.Cid().Equals(expected) {
28+
t.Fatalf("Got CID %s, expected CID %s", nd.Cid(), expected)
29+
}
30+
}
31+
1432
func TestRemoveLink(t *testing.T) {
1533
nd := &ProtoNode{}
1634
nd.SetLinks([]*ipld.Link{

ipld/merkledag/pb/merkledag.pb.go

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

ipld/merkledag/pb/upgrade_check.go

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package merkledag_pb
2+
3+
// Make sure the user doesn't upgrade this package!
4+
// This will fail to build if the user does.
5+
const _ = DoNotUpgradeFileEverItWillChangeYourHashes

0 commit comments

Comments
 (0)