diff --git a/src/core/components/dag.js b/src/core/components/dag.js index e8cecdb7a4..c33539d97c 100644 --- a/src/core/components/dag.js +++ b/src/core/components/dag.js @@ -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', diff --git a/test/core/pin.js b/test/core/pin.js index 32618422a0..2c1b87e329 100644 --- a/test/core/pin.js +++ b/test/core/pin.js @@ -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 () {