Fix lengths in prefix too

This commit is contained in:
Jakub Sztandera
2016-11-17 19:16:05 +01:00
parent c67fe910f2
commit 9116bf8025
2 changed files with 2 additions and 2 deletions

2
cid.go
View File

@@ -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))

View File

@@ -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()
}