diff --git a/.aegir.js b/.aegir.js index 7f287dd89..eb52981d2 100644 --- a/.aegir.js +++ b/.aegir.js @@ -3,6 +3,7 @@ const createServer = require('ipfsd-ctl').createServer const server = createServer() + module.exports = { karma: { files: [{ diff --git a/package.json b/package.json index 3ab6f2812..d94270103 100644 --- a/package.json +++ b/package.json @@ -7,20 +7,22 @@ "glob": false, "fs": false, "stream": "readable-stream", - "http": "stream-http" + "http": "stream-http", + "ipfs-api": false, + "ipfs": false }, "scripts": { "test": "aegir test", "test:node": "aegir test -t node", - "test:browser": "aegir test -t browser", - "test:webworker": "aegir test -t webworker", + "test:browser": "node --max-old-space-size=8192 $(npm bin)/aegir test -t browser", + "test:webworker": "node --max-old-space-size=8192 $(npm bin)/aegir test -t webworker", "lint": "aegir lint", "build": "aegir build", - "release": "aegir release ", - "release-minor": "aegir release --type minor ", - "release-major": "aegir release --type major ", - "coverage": "aegir coverage --timeout 100000", - "coverage-publish": "aegir coverage --provider coveralls --timeout 100000" + "release": "node --max-old-space-size=8192 $(npm bin)/aegir release ", + "release-minor": "node --max-old-space-size=8192 $(npm bin)/aegir release --type minor ", + "release-major": "node --max-old-space-size=8192 $(npm bin)/aegir release --type major ", + "coverage": "node --max-old-space-size=8192 $(npm bin)/aegir coverage --timeout 100000", + "coverage-publish": "anode --max-old-space-size=8192 $(npm bin)/aegir coverage --provider coveralls --timeout 100000" }, "dependencies": { "async": "^2.6.0", @@ -41,14 +43,14 @@ "multihashes": "~0.4.13", "ndjson": "^1.5.0", "once": "^1.4.0", - "peer-id": "~0.10.5", + "peer-id": "~0.10.6", "peer-info": "~0.11.6", "promisify-es6": "^1.0.3", "pull-defer": "^0.2.2", "pull-pushable": "^2.1.2", "pump": "^3.0.0", "qs": "^6.5.1", - "readable-stream": "^2.3.3", + "readable-stream": "^2.3.4", "stream-http": "^2.8.0", "stream-to-pull-stream": "^1.7.2", "streamifier": "^0.1.1", @@ -71,7 +73,7 @@ "gulp": "^3.9.1", "interface-ipfs-core": "~0.48.0", "hapi": "^17.2.0", - "ipfsd-ctl": "~0.27.3", + "ipfsd-ctl": "~0.28.0", "pre-commit": "^1.2.2", "socket.io": "^2.0.4", "socket.io-client": "^2.0.4", diff --git a/test/bitswap.spec.js b/test/bitswap.spec.js index d8364f464..8bd16f2c0 100644 --- a/test/bitswap.spec.js +++ b/test/bitswap.spec.js @@ -8,17 +8,18 @@ chai.use(dirtyChai) const IPFSApi = require('../src') -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('./utils/factory') describe('.bitswap', function () { this.timeout(20 * 1000) // slow CI + let ipfs let ipfsd = null - before((done) => { + before(function (done) { this.timeout(20 * 1000) // slow CI - df.spawn((err, _ipfsd) => { + + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) diff --git a/test/bootstrap.spec.js b/test/bootstrap.spec.js index 4cc7e3221..8a32d5274 100644 --- a/test/bootstrap.spec.js +++ b/test/bootstrap.spec.js @@ -8,9 +8,7 @@ const expect = chai.expect chai.use(dirtyChai) const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('./utils/factory') const invalidArg = 'this/Is/So/Invalid/' const validIp4 = '/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z' @@ -22,7 +20,7 @@ describe('.bootstrap', function () { let ipfs before((done) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) @@ -34,169 +32,81 @@ describe('.bootstrap', function () { let peers - describe('Callback API', function () { - this.timeout(100 * 1000) - - describe('.add', () => { - it('returns an error when called with an invalid arg', (done) => { - ipfs.bootstrap.add(invalidArg, (err) => { - expect(err).to.be.an.instanceof(Error) - done() - }) - }) - - it('returns a list of containing the bootstrap peer when called with a valid arg (ip4)', (done) => { - ipfs.bootstrap.add(validIp4, (err, res) => { - expect(err).to.not.exist() - expect(res).to.be.eql({ Peers: [validIp4] }) - peers = res.Peers - expect(peers).to.exist() - expect(peers.length).to.eql(1) - done() - }) - }) - - it('returns a list of bootstrap peers when called with the default option', (done) => { - ipfs.bootstrap.add({ default: true }, (err, res) => { - expect(err).to.not.exist() - peers = res.Peers - expect(peers).to.exist() - expect(peers.length).to.above(1) - done() - }) + describe('.add', () => { + it('returns an error when called with an invalid arg', (done) => { + ipfs.bootstrap.add(invalidArg, (err) => { + expect(err).to.be.an.instanceof(Error) + done() }) }) - describe('.list', () => { - it('returns a list of peers', (done) => { - ipfs.bootstrap.list((err, res) => { - expect(err).to.not.exist() - peers = res.Peers - expect(peers).to.exist() - done() - }) + it('returns a list of containing the bootstrap peer when called with a valid arg (ip4)', (done) => { + ipfs.bootstrap.add(validIp4, (err, res) => { + expect(err).to.not.exist() + expect(res).to.be.eql({ Peers: [validIp4] }) + peers = res.Peers + expect(peers).to.exist() + expect(peers.length).to.eql(1) + done() }) }) - describe('.rm', () => { - it('returns an error when called with an invalid arg', (done) => { - ipfs.bootstrap.rm(invalidArg, (err) => { - expect(err).to.be.an.instanceof(Error) - done() - }) - }) - - it('returns empty list because no peers removed when called without an arg or options', (done) => { - ipfs.bootstrap.rm(null, (err, res) => { - expect(err).to.not.exist() - peers = res.Peers - expect(peers).to.exist() - expect(peers.length).to.eql(0) - done() - }) - }) - - it('returns list containing the peer removed when called with a valid arg (ip4)', (done) => { - ipfs.bootstrap.rm(null, (err, res) => { - expect(err).to.not.exist() - peers = res.Peers - expect(peers).to.exist() - expect(peers.length).to.eql(0) - done() - }) - }) - - it('returns list of all peers removed when all option is passed', (done) => { - ipfs.bootstrap.rm(null, { all: true }, (err, res) => { - expect(err).to.not.exist() - peers = res.Peers - expect(peers).to.exist() - done() - }) + it('returns a list of bootstrap peers when called with the default option', (done) => { + ipfs.bootstrap.add({ default: true }, (err, res) => { + expect(err).to.not.exist() + peers = res.Peers + expect(peers).to.exist() + expect(peers.length).to.above(1) + done() }) }) }) - describe('Promise API', function () { - this.timeout(100 * 1000) - - describe('.add', () => { - it('returns an error when called without args or options', () => { - return ipfs.bootstrap.add(null) - .catch((err) => { - expect(err).to.be.an.instanceof(Error) - }) - }) - - it('returns an error when called with an invalid arg', () => { - return ipfs.bootstrap.add(invalidArg) - .catch((err) => { - expect(err).to.be.an.instanceof(Error) - }) - }) - - it('returns a list of peers when called with a valid arg (ip4)', () => { - return ipfs.bootstrap.add(validIp4) - .then((res) => { - expect(res).to.be.eql({ Peers: [validIp4] }) - peers = res.Peers - expect(peers).to.exist() - expect(peers.length).to.eql(1) - }) - }) - - it('returns a list of default peers when called with the default option', () => { - return ipfs.bootstrap.add(null, { default: true }) - .then((res) => { - peers = res.Peers - expect(peers).to.exist() - expect(peers.length).to.above(1) - }) + describe('.list', () => { + it('returns a list of peers', (done) => { + ipfs.bootstrap.list((err, res) => { + expect(err).to.not.exist() + peers = res.Peers + expect(peers).to.exist() + done() }) }) + }) - describe('.list', () => { - it('returns a list of peers', () => { - return ipfs.bootstrap.list() - .then((res) => { - peers = res.Peers - expect(peers).to.exist() - }) + describe('.rm', () => { + it('returns an error when called with an invalid arg', (done) => { + ipfs.bootstrap.rm(invalidArg, (err) => { + expect(err).to.be.an.instanceof(Error) + done() }) }) - describe('.rm', () => { - it('returns an error when called with an invalid arg', () => { - return ipfs.bootstrap.rm(invalidArg) - .catch((err) => { - expect(err).to.be.an.instanceof(Error) - }) - }) - - it('returns empty list when called without an arg or options', () => { - return ipfs.bootstrap.rm(null) - .then((res) => { - peers = res.Peers - expect(peers).to.exist() - expect(peers.length).to.eql(0) - }) + it('returns empty list because no peers removed when called without an arg or options', (done) => { + ipfs.bootstrap.rm(null, (err, res) => { + expect(err).to.not.exist() + peers = res.Peers + expect(peers).to.exist() + expect(peers.length).to.eql(0) + done() }) + }) - it('returns list containing the peer removed when called with a valid arg (ip4)', () => { - return ipfs.bootstrap.rm(null) - .then((res) => { - peers = res.Peers - expect(peers).to.exist() - expect(peers.length).to.eql(0) - }) + it('returns list containing the peer removed when called with a valid arg (ip4)', (done) => { + ipfs.bootstrap.rm(null, (err, res) => { + expect(err).to.not.exist() + peers = res.Peers + expect(peers).to.exist() + expect(peers.length).to.eql(0) + done() }) + }) - it('returns list of all peers removed when all option is passed', () => { - return ipfs.bootstrap.rm(null, { all: true }) - .then((res) => { - peers = res.Peers - expect(peers).to.exist() - }) + it('returns list of all peers removed when all option is passed', (done) => { + ipfs.bootstrap.rm(null, { all: true }, (err, res) => { + expect(err).to.not.exist() + peers = res.Peers + expect(peers).to.exist() + done() }) }) }) diff --git a/test/commands.spec.js b/test/commands.spec.js index 5e2b3804d..cb69c0b8b 100644 --- a/test/commands.spec.js +++ b/test/commands.spec.js @@ -8,8 +8,7 @@ chai.use(dirtyChai) const IPFSApi = require('../src') -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('./utils/factory') describe('.commands', function () { this.timeout(20 * 1000) @@ -18,7 +17,7 @@ describe('.commands', function () { let ipfs before((done) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) diff --git a/test/constructor.spec.js b/test/constructor.spec.js index 46ef3fb3e..74042c176 100644 --- a/test/constructor.spec.js +++ b/test/constructor.spec.js @@ -6,9 +6,7 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() - +const f = require('./utils/factory') const ipfsAPI = require('../src/index.js') function clientWorks (client, done) { @@ -28,7 +26,8 @@ describe('ipfs-api constructor tests', () => { before(function (done) { this.timeout(20 * 1000) // slow CI - df.spawn((err, node) => { + + f.spawn((err, node) => { expect(err).to.not.exist() ipfsd = node apiAddr = node.apiAddr.toString() diff --git a/test/diag.spec.js b/test/diag.spec.js index 5f68a3e95..ef2f7c605 100644 --- a/test/diag.spec.js +++ b/test/diag.spec.js @@ -8,23 +8,19 @@ chai.use(dirtyChai) const os = require('os') const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('./utils/factory') describe('.diag', function () { this.timeout(50 * 1000) - if (os.platform() === 'win32') { - it('skip these on Windows') - return - } + // go-ipfs does not support these on Windows + if (os.platform() === 'win32') { return } let ipfsd let ipfs before((done) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) diff --git a/test/files.spec.js b/test/files.spec.js index 3c88e26b5..5fb8bb3c3 100644 --- a/test/files.spec.js +++ b/test/files.spec.js @@ -12,9 +12,7 @@ const mh = require('multihashes') const CID = require('cids') const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('./utils/factory') const testfile = isNode ? loadFixture(__dirname, '/fixtures/testfile.txt') @@ -41,7 +39,7 @@ describe('.files (the MFS API part)', function () { const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' before((done) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) diff --git a/test/get.spec.js b/test/get.spec.js index 3cd9e99c6..3de97f21b 100644 --- a/test/get.spec.js +++ b/test/get.spec.js @@ -12,9 +12,7 @@ const series = require('async/series') const loadFixture = require('aegir/fixtures') const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('./utils/factory') describe('.get (specific go-ipfs features)', function () { this.timeout(20 * 1000) @@ -33,7 +31,7 @@ describe('.get (specific go-ipfs features)', function () { before((done) => { series([ - (cb) => df.spawn((err, _ipfsd) => { + (cb) => f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) diff --git a/test/interface/block.spec.js b/test/interface/block.spec.js index 5a1883088..b7b4181cf 100644 --- a/test/interface/block.spec.js +++ b/test/interface/block.spec.js @@ -6,16 +6,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { callback(null, { spawnNode: (cb) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { if (err) { return cb(err) } diff --git a/test/interface/config.spec.js b/test/interface/config.spec.js index 91f551a7d..0c47b099b 100644 --- a/test/interface/config.spec.js +++ b/test/interface/config.spec.js @@ -6,16 +6,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { callback(null, { spawnNode: (cb) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { if (err) { return cb(err) } diff --git a/test/interface/dht.spec.js b/test/interface/dht.spec.js index 1ae3081fc..4e02d8343 100644 --- a/test/interface/dht.spec.js +++ b/test/interface/dht.spec.js @@ -5,16 +5,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { callback(null, { spawnNode: (cb) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { if (err) { return cb(err) } diff --git a/test/interface/files.spec.js b/test/interface/files.spec.js index c58b9d5e8..2b464be20 100644 --- a/test/interface/files.spec.js +++ b/test/interface/files.spec.js @@ -6,16 +6,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { callback(null, { spawnNode: (cb) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { if (err) { return cb(err) } diff --git a/test/interface/key.spec.js b/test/interface/key.spec.js index 6fd3510f5..b34221f70 100644 --- a/test/interface/key.spec.js +++ b/test/interface/key.spec.js @@ -6,16 +6,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { callback(null, { spawnNode: (cb) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { if (err) { return cb(err) } diff --git a/test/interface/miscellaneous.spec.js b/test/interface/miscellaneous.spec.js index f7d03f3de..1d203604e 100644 --- a/test/interface/miscellaneous.spec.js +++ b/test/interface/miscellaneous.spec.js @@ -5,16 +5,14 @@ const test = require('interface-ipfs-core') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { callback(null, { spawnNode: (cb) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { if (err) { return cb(err) } diff --git a/test/interface/object.spec.js b/test/interface/object.spec.js index be4ffa70c..bdc74e227 100644 --- a/test/interface/object.spec.js +++ b/test/interface/object.spec.js @@ -6,16 +6,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { callback(null, { spawnNode: (cb) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { if (err) { return cb(err) } diff --git a/test/interface/pin.spec.js b/test/interface/pin.spec.js index d72d008b3..dd7891461 100644 --- a/test/interface/pin.spec.js +++ b/test/interface/pin.spec.js @@ -6,16 +6,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { callback(null, { spawnNode: (cb) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { if (err) { return cb(err) } diff --git a/test/interface/pubsub.spec.js b/test/interface/pubsub.spec.js index 4499bcbce..ddba34e2a 100644 --- a/test/interface/pubsub.spec.js +++ b/test/interface/pubsub.spec.js @@ -8,9 +8,7 @@ const isNode = require('detect-node') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('../utils/factory') if (isNode) { const nodes = [] @@ -18,7 +16,7 @@ if (isNode) { setup: function (callback) { callback(null, { spawnNode: (cb) => { - df.spawn({ args: ['--enable-pubsub-experiment'] }, + f.spawn({ args: ['--enable-pubsub-experiment'] }, (err, _ipfsd) => { if (err) { return cb(err) diff --git a/test/interface/repo.spec.js b/test/interface/repo.spec.js index acce37e75..211f8bb41 100644 --- a/test/interface/repo.spec.js +++ b/test/interface/repo.spec.js @@ -6,16 +6,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { callback(null, { spawnNode: (cb) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { if (err) { return cb(err) } diff --git a/test/interface/stats.spec.js b/test/interface/stats.spec.js index 6186c33db..1a2a9aa15 100644 --- a/test/interface/stats.spec.js +++ b/test/interface/stats.spec.js @@ -6,16 +6,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { callback(null, { spawnNode: (cb) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { if (err) { return cb(err) } diff --git a/test/interface/swarm.spec.js b/test/interface/swarm.spec.js index 6d04fbcd8..735f60d95 100644 --- a/test/interface/swarm.spec.js +++ b/test/interface/swarm.spec.js @@ -6,9 +6,7 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('../utils/factory') const nodes = [] const common = { @@ -25,7 +23,7 @@ const common = { config = undefined } - df.spawn({ repoPath, config }, (err, _ipfsd) => { + f.spawn({ repoPath, config }, (err, _ipfsd) => { if (err) { return cb(err) } diff --git a/test/key.spec.js b/test/key.spec.js index 3db9a9953..5d958708f 100644 --- a/test/key.spec.js +++ b/test/key.spec.js @@ -8,9 +8,7 @@ const expect = chai.expect chai.use(dirtyChai) const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('./utils/factory') describe('.key', function () { this.timeout(50 * 1000) @@ -19,7 +17,7 @@ describe('.key', function () { let ipfs before((done) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) diff --git a/test/log.spec.js b/test/log.spec.js index 38dc7d710..4c780e37d 100644 --- a/test/log.spec.js +++ b/test/log.spec.js @@ -8,9 +8,7 @@ const expect = chai.expect chai.use(dirtyChai) const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('./utils/factory') describe('.log', function () { this.timeout(100 * 1000) @@ -19,7 +17,7 @@ describe('.log', function () { let ipfs before((done) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) @@ -29,76 +27,39 @@ describe('.log', function () { after((done) => ipfsd.stop(done)) - describe('Callback API', function () { - this.timeout(100 * 1000) - - it('.log.tail', (done) => { - const req = ipfs.log.tail((err, res) => { - expect(err).to.not.exist() - expect(req).to.exist() - - res.once('data', (obj) => { - expect(obj).to.be.an('object') - done() - }) - }) - }) - - it('.log.ls', (done) => { - ipfs.log.ls((err, res) => { - expect(err).to.not.exist() - expect(res).to.exist() - - expect(res).to.be.an('array') + it('.log.tail', (done) => { + const req = ipfs.log.tail((err, res) => { + expect(err).to.not.exist() + expect(req).to.exist() + res.once('data', (obj) => { + expect(obj).to.be.an('object') done() }) }) + }) - it('.log.level', (done) => { - ipfs.log.level('all', 'error', (err, res) => { - expect(err).to.not.exist() - expect(res).to.exist() + it('.log.ls', (done) => { + ipfs.log.ls((err, res) => { + expect(err).to.not.exist() + expect(res).to.exist() - expect(res).to.be.an('object') - expect(res).to.not.have.property('Error') - expect(res).to.have.property('Message') + expect(res).to.be.an('array') - done() - }) + done() }) }) - describe('Promise API', function () { - this.timeout(100 * 1000) - - it('.log.tail', () => { - return ipfs.log.tail() - .then((res) => { - res.once('data', (obj) => { - expect(obj).to.be.an('object') - }) - }) - }) - - it('.log.ls', () => { - return ipfs.log.ls() - .then((res) => { - expect(res).to.exist() - - expect(res).to.be.an('array') - }) - }) + it('.log.level', (done) => { + ipfs.log.level('all', 'error', (err, res) => { + expect(err).to.not.exist() + expect(res).to.exist() - it('.log.level', () => { - return ipfs.log.level('all', 'error') - .then((res) => { - expect(res).to.exist() + expect(res).to.be.an('object') + expect(res).to.not.have.property('Error') + expect(res).to.have.property('Message') - expect(res).to.be.an('object') - expect(res).to.not.have.property('Error') - expect(res).to.have.property('Message') - }) + done() }) }) }) diff --git a/test/mount.spec.js b/test/mount.spec.js deleted file mode 100644 index 15f725edb..000000000 --- a/test/mount.spec.js +++ /dev/null @@ -1,7 +0,0 @@ -/* eslint-env mocha */ -'use strict' - -// requires FUSE to be installed, not practical for testing -describe('.mount', () => { - it('missing') -}) diff --git a/test/name.spec.js b/test/name.spec.js index 4cf1088f9..bffe573c4 100644 --- a/test/name.spec.js +++ b/test/name.spec.js @@ -12,26 +12,25 @@ const series = require('async/series') const loadFixture = require('aegir/fixtures') const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('./utils/factory') const testfile = isNode ? loadFixture(__dirname, '/fixtures/testfile.txt') : loadFixture(__dirname, 'fixtures/testfile.txt') -describe('.name', function () { - this.timeout(50 * 1000) - +describe('.name', () => { let ipfs let ipfsd let other let otherd + let name + + before(function (done) { + this.timeout(20 * 1000) - before((done) => { series([ (cb) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) @@ -39,7 +38,7 @@ describe('.name', function () { }) }, (cb) => { - df.spawn((err, node) => { + f.spawn((err, node) => { expect(err).to.not.exist() other = node.api otherd = node @@ -63,60 +62,36 @@ describe('.name', function () { ], done) }) - describe('Callback API', () => { - let name + it('add file for testing', (done) => { + const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' - it('add file for testing', (done) => { - const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' - - ipfs.files.add(testfile, (err, res) => { - expect(err).to.not.exist() - - expect(res).to.have.length(1) - expect(res[0].hash).to.equal(expectedMultihash) - expect(res[0].path).to.equal(expectedMultihash) - done() - }) - }) + ipfs.files.add(testfile, (err, res) => { + expect(err).to.not.exist() - it('.name.publish', function (done) { - this.timeout(100 * 1000) - ipfs.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { - expect(err).to.not.exist() - name = res - expect(name).to.exist() - done() - }) - }) - - it('.name.resolve', (done) => { - ipfs.name.resolve(name.name, (err, res) => { - expect(err).to.not.exist() - expect(res).to.exist() - expect(res).to.be.eql(name.value) - done() - }) + expect(res).to.have.length(1) + expect(res[0].hash).to.equal(expectedMultihash) + expect(res[0].path).to.equal(expectedMultihash) + done() }) }) - describe('Promise API', () => { - let name + it('.name.publish', function (done) { + this.timeout(100 * 1000) - it('.name.publish', function () { - this.timeout(80 * 1000) - return ipfs.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP') - .then((res) => { - name = res - expect(name).to.exist() - }) + ipfs.name.publish('Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP', (err, res) => { + expect(err).to.not.exist() + name = res + expect(name).to.exist() + done() }) + }) - it('.name.resolve', () => { - return ipfs.name.resolve(name.name) - .then((res) => { - expect(res).to.exist() - expect(res).to.be.eql(name.value) - }) + it('.name.resolve', (done) => { + ipfs.name.resolve(name.name, (err, res) => { + expect(err).to.not.exist() + expect(res).to.exist() + expect(res).to.be.eql(name.value) + done() }) }) }) diff --git a/test/ping.spec.js b/test/ping.spec.js index e2bcc44ff..c39673615 100644 --- a/test/ping.spec.js +++ b/test/ping.spec.js @@ -10,9 +10,7 @@ const parallel = require('async/parallel') const series = require('async/series') const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('./utils/factory') describe.skip('.ping', () => { let ipfs @@ -22,9 +20,10 @@ describe.skip('.ping', () => { before(function (done) { this.timeout(20 * 1000) // slow CI + series([ (cb) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) @@ -33,7 +32,7 @@ describe.skip('.ping', () => { }, (cb) => { console.log('going to spawn second node') - df.spawn((err, node) => { + f.spawn((err, node) => { expect(err).to.not.exist() other = node.api otherd = node diff --git a/test/pubsub-in-browser.spec.js b/test/pubsub-in-browser.spec.js index 818b477bb..95070e459 100644 --- a/test/pubsub-in-browser.spec.js +++ b/test/pubsub-in-browser.spec.js @@ -33,26 +33,21 @@ const expect = chai.expect chai.use(dirtyChai) const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('./utils/factory') const expectedError = 'pubsub is currently not supported when run in the browser' -describe('.pubsub-browser (pubsub not supported in the browsers currently)', function () { +describe('.pubsub is not supported in the browser, yet!', function () { this.timeout(50 * 1000) - if (isNode) { - it('skip these in Node.js') - return - } - const topic = 'pubsub-tests' + if (isNode) { return } + const topic = 'pubsub-tests' let ipfs let ipfsd before((done) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) diff --git a/test/refs.spec.js b/test/refs.spec.js index d6ca6572d..d74717597 100644 --- a/test/refs.spec.js +++ b/test/refs.spec.js @@ -11,16 +11,12 @@ const path = require('path') const fs = require('fs') const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('./utils/factory') describe('.refs', function () { this.timeout(80 * 1000) - if (!isNode) { - return - } + if (!isNode) { return } let ipfs let ipfsd @@ -39,7 +35,7 @@ describe('.refs', function () { } waterfall([ - (cb) => df.spawn(cb), + (cb) => f.spawn(cb), (_ipfsd, cb) => { ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) diff --git a/test/repo.spec.js b/test/repo.spec.js index baf9525d9..ee3f7f0b6 100644 --- a/test/repo.spec.js +++ b/test/repo.spec.js @@ -7,9 +7,7 @@ const expect = chai.expect chai.use(dirtyChai) const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('./utils/factory') describe('.repo', function () { this.timeout(50 * 1000) // slow CI @@ -18,7 +16,7 @@ describe('.repo', function () { let ipfsd before((done) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) @@ -28,53 +26,29 @@ describe('.repo', function () { after((done) => ipfsd.stop(done)) - describe('Callback API', () => { - it('.repo.gc', (done) => { - ipfs.repo.gc((err, res) => { - expect(err).to.not.exist() - expect(res).to.exist() - done() - }) - }) - - it('.repo.stat', (done) => { - ipfs.repo.stat((err, res) => { - expect(err).to.not.exist() - expect(res).to.exist() - expect(res).to.have.a.property('numObjects') - expect(res).to.have.a.property('repoSize') - done() - }) - }) - - it('.repo.version', (done) => { - ipfs.repo.version((err, res) => { - expect(err).to.not.exist() - expect(res).to.exist() - done() - }) + it('.repo.gc', (done) => { + ipfs.repo.gc((err, res) => { + expect(err).to.not.exist() + expect(res).to.exist() + done() }) }) - describe('Promise API', () => { - it('.repo.gc', () => { - return ipfs.repo.gc().then((res) => expect(res).to.exist()) - }) - - it('.repo.stat', () => { - return ipfs.repo.stat() - .then((res) => { - expect(res).to.exist() - expect(res).to.have.a.property('numObjects') - expect(res).to.have.a.property('repoSize') - }) + it('.repo.stat', (done) => { + ipfs.repo.stat((err, res) => { + expect(err).to.not.exist() + expect(res).to.exist() + expect(res).to.have.a.property('numObjects') + expect(res).to.have.a.property('repoSize') + done() }) + }) - it('.repo.version', () => { - return ipfs.repo.version() - .then(res => { - expect(res).to.exist() - }) + it('.repo.version', (done) => { + ipfs.repo.version((err, res) => { + expect(err).to.not.exist() + expect(res).to.exist() + done() }) }) }) diff --git a/test/stats.spec.js b/test/stats.spec.js index 1f1619157..73cd29774 100644 --- a/test/stats.spec.js +++ b/test/stats.spec.js @@ -7,9 +7,7 @@ const expect = chai.expect chai.use(dirtyChai) const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('./utils/factory') describe('stats', function () { this.timeout(50 * 1000) // slow CI @@ -18,7 +16,7 @@ describe('stats', function () { let ipfsd before((done) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) diff --git a/test/update.spec.js b/test/update.spec.js deleted file mode 100644 index 986885bc7..000000000 --- a/test/update.spec.js +++ /dev/null @@ -1,8 +0,0 @@ -/* eslint-env mocha */ -'use strict' - -describe('.update (currently not available through ipfs-api)', () => { - it('.update.apply') - it('.update.check') - it('.update.log') -}) diff --git a/test/util.spec.js b/test/util.spec.js index 89b81414b..1573620fd 100644 --- a/test/util.spec.js +++ b/test/util.spec.js @@ -11,9 +11,7 @@ const path = require('path') const fs = require('fs') const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const f = require('./utils/factory') describe('.util', () => { if (!isNode) { return } @@ -24,7 +22,7 @@ describe('.util', () => { before(function (done) { this.timeout(20 * 1000) // slow CI - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) diff --git a/test/utils/factory.js b/test/utils/factory.js new file mode 100644 index 000000000..957393536 --- /dev/null +++ b/test/utils/factory.js @@ -0,0 +1,3 @@ +const IPFSFactory = require('ipfsd-ctl') + +module.exports = IPFSFactory.create()