Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Commit 51105b6

Browse files
authored
fix: fix support for identity multihash (#93)
1 parent 5c22ce8 commit 51105b6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/index.spec.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,23 @@ describe('CID', () => {
186186
expect(cid.prefix.toString('hex')).to.equal('01711220')
187187
})
188188

189+
it('.prefix identity multihash', () => {
190+
const mh = multihash.encode(Buffer.from('abc'), 'identity')
191+
const cid0 = new CID(0, 'dag-pb', mh)
192+
193+
expect(cid0).to.have.property('codec', 'dag-pb')
194+
expect(cid0).to.have.property('version', 0)
195+
expect(cid0).to.have.property('multihash').that.eql(mh)
196+
expect(cid0.toBaseEncodedString()).to.eql('161g3c')
197+
198+
const cid1 = new CID(1, 'dag-cbor', mh)
199+
200+
expect(cid1).to.have.property('codec', 'dag-cbor')
201+
expect(cid1).to.have.property('version', 1)
202+
expect(cid1).to.have.property('multihash').that.eql(mh)
203+
expect(cid1.toBaseEncodedString()).to.eql('bafyqaa3bmjrq')
204+
})
205+
189206
it('.buffer', () => {
190207
const codec = 'dag-cbor' // Invalid codec will cause an error: Issue #46
191208
const cid = new CID(1, codec, hash)

0 commit comments

Comments
 (0)