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
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Aug 8, 2019
1 parent d363f93 commit 8ee3d9f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"class-is": "^1.1.0",
"multibase": "~0.6.0",
"multicodec": "~0.5.1",
"multihashes": "~0.4.14"
"multihashes": "~0.4.15"
},
"devDependencies": {
"aegir": "^18.2.0",
Expand Down
17 changes: 17 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,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 8ee3d9f

Please sign in to comment.