Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

fix(dag): check dag.put options for plain object #1480

Merged
merged 3 commits into from
Aug 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/core/components/dag.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ module.exports = function dag (self) {
put: promisify((dagNode, options, callback) => {
if (typeof options === 'function') {
callback = options
} else if (options.cid && (options.format || options.hashAlg)) {
options = {}
} else if (options && options.cid && (options.format || options.hashAlg)) {
return callback(new Error('Can\'t put dag node. Please provide either `cid` OR `format` and `hashAlg` options.'))
} else if ((options.format && !options.hashAlg) || (!options.format && options.hashAlg)) {
} else if (options && ((options.format && !options.hashAlg) || (!options.format && options.hashAlg))) {
return callback(new Error('Can\'t put dag node. Please provide `format` AND `hashAlg` options.'))
}
options = options || {}

const optionDefaults = {
format: 'dag-cbor',
Expand Down
5 changes: 4 additions & 1 deletion test/core/pin.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@ describe('pin', function () {
})
})

after(done => ipfs.stop(done))
after(function (done) {
this.timeout(20 * 1000)
ipfs.stop(done)
})

describe('isPinnedWithType', function () {
beforeEach(function () {
Expand Down