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

Commit

Permalink
fix: fix support for identity multihash (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Jun 16, 2020
1 parent 5c22ce8 commit 51105b6
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,23 @@ describe('CID', () => {
expect(cid.prefix.toString('hex')).to.equal('01711220')
})

it('.prefix identity multihash', () => {
const mh = multihash.encode(Buffer.from('abc'), 'identity')
const cid0 = new CID(0, 'dag-pb', mh)

expect(cid0).to.have.property('codec', 'dag-pb')
expect(cid0).to.have.property('version', 0)
expect(cid0).to.have.property('multihash').that.eql(mh)
expect(cid0.toBaseEncodedString()).to.eql('161g3c')

const cid1 = new CID(1, 'dag-cbor', mh)

expect(cid1).to.have.property('codec', 'dag-cbor')
expect(cid1).to.have.property('version', 1)
expect(cid1).to.have.property('multihash').that.eql(mh)
expect(cid1.toBaseEncodedString()).to.eql('bafyqaa3bmjrq')
})

it('.buffer', () => {
const codec = 'dag-cbor' // Invalid codec will cause an error: Issue #46
const cid = new CID(1, codec, hash)
Expand Down

0 comments on commit 51105b6

Please sign in to comment.