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

Commit

Permalink
fix: respect the cidVersion option
Browse files Browse the repository at this point in the history
The [interface-ipld-format spec](https://github.com/ipld/interface-ipld-format#utilcidbinaryblob-options)
says the CID verison option is `cidVersion`.  This module passes it
to formats as `version` which is subsequently ignored.
  • Loading branch information
achingbrain authored and vmx committed May 15, 2019
1 parent 8a45949 commit b1a3a2a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class IPLDResolver {
const options = mergeOptions(defaultOptions, userOptions)

const cidOptions = {
version: options.cidVersion,
cidVersion: options.cidVersion,
hashAlg: options.hashAlg,
onlyHash: options.onlyHash
}
Expand Down
18 changes: 18 additions & 0 deletions test/ipld-dag-pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,24 @@ module.exports = (repo) => {
await expect(resolver.get(cid)).to.eventually.be.rejected()
}
})

it('should return a v0 CID when specified', async () => {
const node = dagPB.DAGNode.create(Buffer.from('a dag-pb node'))
const cid = await resolver.put(node, multicodec.DAG_PB, {
cidVersion: 0
})

expect(cid.version).to.equal(0)
})

it('should return a v1 CID when specified', async () => {
const node = dagPB.DAGNode.create(Buffer.from('a dag-pb node'))
const cid = await resolver.put(node, multicodec.DAG_PB, {
cidVersion: 1
})

expect(cid.version).to.equal(1)
})
})
})
}

0 comments on commit b1a3a2a

Please sign in to comment.