Skip to content

Commit

Permalink
test(dag): add test to verify put API overrides hash algorithm
Browse files Browse the repository at this point in the history
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
  • Loading branch information
0x-r4bbit committed Jul 4, 2018
1 parent 7660e0f commit 404b929
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions js/src/dag/put.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ module.exports = (createCommon, options) => {
})
})

it.skip('should override hash algoritm default and resolve with it', (done) => {
ipfs.dag.put(cborNode, {
format: 'dag-cbor',
hashAlg: 'sha3-512'
}, (err, cid) => {
expect(err).to.not.exist()
expect(cid.codec).to.equal('dag-cbor')
expect(multihash.decode(cid.multihash).name).to.equal('sha3-512')
done()
})
})

it.skip('should put by passing the cid instead of format and hashAlg', (done) => {})

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

0 comments on commit 404b929

Please sign in to comment.