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

Commit

Permalink
feat: add defaultHashAlg
Browse files Browse the repository at this point in the history
  • Loading branch information
richardschneider committed Jun 22, 2018
1 parent 20f7a66 commit d0ccec3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const traverse = require('traverse')
exports = module.exports

exports.multicodec = 'git-raw'
exports.defaultHashAlg = 'sha1'

const personInfoPaths = [
'original',
Expand Down
2 changes: 1 addition & 1 deletion src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ exports.deserialize = (data, callback) => {
exports.cid = (dagNode, callback) => {
waterfall([
(cb) => exports.serialize(dagNode, cb),
(serialized, cb) => multihashing(serialized, 'sha1', cb),
(serialized, cb) => multihashing(serialized, resolver.defaultHashAlg, cb),
(mh, cb) => cb(null, new CID(1, resolver.multicodec, mh))
], callback)
}
12 changes: 12 additions & 0 deletions test/resolver.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,15 @@ describe('IPLD format resolver (local)', () => {
})
})
})

describe('IPLD format resolver API properties', () => {
it('should have `multicodec` defined correctly', (done) => {
expect(resolver.multicodec).to.equal('git-raw')
done()
})

it('should have `defaultHashAlg` defined correctly', (done) => {
expect(resolver.defaultHashAlg).to.equal('sha1')
done()
})
})

0 comments on commit d0ccec3

Please sign in to comment.