Unverified Commit 64bc8442 authored by Steven Allen's avatar Steven Allen Committed by GitHub

Merge pull request #4 from ipfs/fix/upgrade-protobuf

update gogo protobuf
parents 5d5535f0 4726b1ee
...@@ -13,6 +13,11 @@ import ( ...@@ -13,6 +13,11 @@ import (
ipld "github.com/ipfs/go-ipld-format" ipld "github.com/ipfs/go-ipld-format"
) )
// Make sure the user doesn't upgrade this file.
// We need to check *here* as well as inside the `pb` package *just* in case the
// user replaces *all* go files in that package.
const _ = pb.DoNotUpgradeFileEverItWillChangeYourHashes
// for now, we use a PBNode intermediate thing. // for now, we use a PBNode intermediate thing.
// because native go objects are nice. // because native go objects are nice.
......
...@@ -9,8 +9,26 @@ import ( ...@@ -9,8 +9,26 @@ import (
mdtest "github.com/ipfs/go-merkledag/test" mdtest "github.com/ipfs/go-merkledag/test"
ipld "github.com/ipfs/go-ipld-format" ipld "github.com/ipfs/go-ipld-format"
cid "github.com/ipfs/go-cid"
) )
func TestStableCID(t *testing.T) {
nd := &ProtoNode{}
nd.SetData([]byte("foobar"))
nd.SetLinks([]*ipld.Link{
{Name: "a"},
{Name: "b"},
{Name: "c"},
})
expected, err := cid.Decode("QmSN3WED2xPLbYvBbfvew2ZLtui8EbFYYcbfkpKH5jwG9C")
if err != nil {
t.Fatal(err)
}
if !nd.Cid().Equals(expected) {
t.Fatalf("Got CID %s, expected CID %s", nd.Cid(), expected)
}
}
func TestRemoveLink(t *testing.T) { func TestRemoveLink(t *testing.T) {
nd := &ProtoNode{} nd := &ProtoNode{}
nd.SetLinks([]*ipld.Link{ nd.SetLinks([]*ipld.Link{
......
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
}, },
{ {
"author": "whyrusleeping", "author": "whyrusleeping",
"hash": "QmZ4Qi3GaRbjcx28Sme5eMH7RQjGkt8wHxt2a65oLaeFEV", "hash": "Qme4mBZ8DawL9xJPSzoEnFCHPzEAZ7NTNYoXSqgVBXpXeo",
"name": "gogo-protobuf", "name": "gogo-protobuf",
"version": "0.0.0" "version": "0.0.0"
}, },
......
...@@ -31,6 +31,15 @@ import strconv "strconv" ...@@ -31,6 +31,15 @@ import strconv "strconv"
import bytes "bytes" import bytes "bytes"
// DoNotUpgradeFileEverItWillChangeYourHashes warns users about not breaking
// their file hashes.
const DoNotUpgradeFileEverItWillChangeYourHashes = `
This file does not produce canonical protobufs. Unfortunately, if we change it,
we'll change the hashes of the files we produce.
Do *not regenerate this file.
`
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal var _ = proto.Marshal
var _ = math.Inf var _ = math.Inf
......
package merkledag_pb
// Make sure the user doesn't upgrade this package!
// This will fail to build if the user does.
const _ = DoNotUpgradeFileEverItWillChangeYourHashes
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