From 9116bf80253f5e5a5d2dbac8c08f202d4045cf7c Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 17 Nov 2016 19:16:05 +0100 Subject: [PATCH] Fix lengths in prefix too --- cid.go | 2 +- cid_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cid.go b/cid.go index bf553ea..04cc09a 100644 --- a/cid.go +++ b/cid.go @@ -266,7 +266,7 @@ func (p Prefix) Sum(data []byte) (*Cid, error) { } func (p Prefix) Bytes() []byte { - buf := make([]byte, 16) + buf := make([]byte, 4*binary.MaxVarintLen64) n := binary.PutUvarint(buf, p.Version) n += binary.PutUvarint(buf[n:], p.Codec) n += binary.PutUvarint(buf[n:], uint64(p.MhType)) diff --git a/cid_test.go b/cid_test.go index e6e479e..c03e281 100644 --- a/cid_test.go +++ b/cid_test.go @@ -124,7 +124,7 @@ func Test16BytesVarint(t *testing.T) { hash, _ := mh.Sum(data, mh.SHA2_256, -1) c := NewCidV1(CBOR, hash) - c.codec = 1 << 54 + c.codec = 1 << 63 _ = c.Bytes() }