Commit 4726b1ee authored by Steven Allen's avatar Steven Allen

add a stable-cid test

This test fails if the protobuf file is regenerated.
parent 682c569e
...@@ -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{
......
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