Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 1c6c9f0

Browse files
0x-r4bbitalanshaw
authored andcommitted
test(dag): add test to verify put API overrides hash algorithm (#323)
As discussed in ipfs/js-ipfs#1419 (comment) at the time of this commit, `dag.put()` basically ignores the `hashAlg` option, as it passes it down to `ipld.put()`, which won't honor it until ipld/js-ipld#133 is merged. Once ipld/js-ipld#133 is merged, this test verifies that e.g. ``` dag.put(cborNode, { format: 'dag-cbor', hashAlg: 'sha3-512' }, (err, cid) => { ... }) ``` Actually results in a `CID` instance that decodes to `sha3-512` and not the `sha2-256` default. License: MIT Signed-off-by: Pascal Precht pascal.precht@gmail.com
1 parent 83e410a commit 1c6c9f0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

js/src/dag/put.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ module.exports = (createCommon, options) => {
109109
})
110110
})
111111

112+
it('should override hash algoritm default and resolve with it', (done) => {
113+
ipfs.dag.put(cborNode, {
114+
format: 'dag-cbor',
115+
hashAlg: 'sha3-512'
116+
}, (err, cid) => {
117+
expect(err).to.not.exist()
118+
expect(cid.codec).to.equal('dag-cbor')
119+
expect(multihash.decode(cid.multihash).name).to.equal('sha3-512')
120+
done()
121+
})
122+
})
123+
112124
it.skip('should put by passing the cid instead of format and hashAlg', (done) => {})
113125

114126
// TODO it.skip('Promises support', (done) => {})

0 commit comments

Comments
 (0)