From 455473827259cf0b7f2c7b2ca287ed3bf075619d Mon Sep 17 00:00:00 2001 From: David Dias Date: Wed, 7 Feb 2018 10:37:42 +0000 Subject: [PATCH 01/10] wip --- .aegir.js | 3 ++- test/bitswap.spec.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.aegir.js b/.aegir.js index 7f287dd89..1e5673304 100644 --- a/.aegir.js +++ b/.aegir.js @@ -2,7 +2,8 @@ const createServer = require('ipfsd-ctl').createServer -const server = createServer() +const server = createServer(30003) + module.exports = { karma: { files: [{ diff --git a/test/bitswap.spec.js b/test/bitswap.spec.js index d8364f464..a29e42db0 100644 --- a/test/bitswap.spec.js +++ b/test/bitswap.spec.js @@ -9,15 +9,16 @@ chai.use(dirtyChai) const IPFSApi = require('../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() +const df = DaemonFactory.create({remote: true, port: 30003}) -describe('.bitswap', function () { +describe.only('.bitswap', function () { this.timeout(20 * 1000) // slow CI let ipfs let ipfsd = null before((done) => { this.timeout(20 * 1000) // slow CI + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd From 1894216eb8f67082a88efb08f51a75c68febcef3 Mon Sep 17 00:00:00 2001 From: David Dias Date: Wed, 7 Feb 2018 10:51:20 +0000 Subject: [PATCH 02/10] use remote daemon factory --- test/bitswap.spec.js | 8 ++-- test/bootstrap.spec.js | 3 +- test/commands.spec.js | 3 +- test/constructor.spec.js | 5 ++- test/diag.spec.js | 9 ++-- test/files.spec.js | 3 +- test/interface/block.spec.js | 3 +- test/interface/config.spec.js | 3 +- test/interface/dht.spec.js | 3 +- test/interface/files.spec.js | 3 +- test/interface/key.spec.js | 3 +- test/interface/miscellaneous.spec.js | 3 +- test/interface/object.spec.js | 3 +- test/interface/pin.spec.js | 3 +- test/interface/pubsub.spec.js | 3 +- test/interface/repo.spec.js | 3 +- test/interface/stats.spec.js | 3 +- test/interface/swarm.spec.js | 3 +- test/key.spec.js | 3 +- test/log.spec.js | 3 +- test/mount.spec.js | 7 ---- test/name.spec.js | 3 +- test/ping.spec.js | 4 +- test/pubsub-in-browser.spec.js | 12 +++--- test/refs.spec.js | 7 ++-- test/repo.spec.js | 63 +++++++++------------------- test/stats.spec.js | 3 +- test/update.spec.js | 8 ---- test/util.spec.js | 3 +- 29 files changed, 83 insertions(+), 100 deletions(-) delete mode 100644 test/mount.spec.js delete mode 100644 test/update.spec.js diff --git a/test/bitswap.spec.js b/test/bitswap.spec.js index a29e42db0..4b911d6e4 100644 --- a/test/bitswap.spec.js +++ b/test/bitswap.spec.js @@ -9,16 +9,18 @@ chai.use(dirtyChai) const IPFSApi = require('../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create({remote: true, port: 30003}) -describe.only('.bitswap', function () { +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 + const df = DaemonFactory.create({remote: true, port: 30003}) + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd diff --git a/test/bootstrap.spec.js b/test/bootstrap.spec.js index 4cc7e3221..53c879951 100644 --- a/test/bootstrap.spec.js +++ b/test/bootstrap.spec.js @@ -10,7 +10,6 @@ chai.use(dirtyChai) const IPFSApi = require('../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() const invalidArg = 'this/Is/So/Invalid/' const validIp4 = '/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z' @@ -22,6 +21,8 @@ describe('.bootstrap', function () { let ipfs before((done) => { + const df = DaemonFactory.create({remote: true, port: 30003}) + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd diff --git a/test/commands.spec.js b/test/commands.spec.js index 5e2b3804d..195f01b5c 100644 --- a/test/commands.spec.js +++ b/test/commands.spec.js @@ -9,7 +9,6 @@ chai.use(dirtyChai) const IPFSApi = require('../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() describe('.commands', function () { this.timeout(20 * 1000) @@ -18,6 +17,8 @@ describe('.commands', function () { let ipfs before((done) => { + const df = DaemonFactory.create({remote: true, port: 30003}) + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd diff --git a/test/constructor.spec.js b/test/constructor.spec.js index 46ef3fb3e..5dfed1722 100644 --- a/test/constructor.spec.js +++ b/test/constructor.spec.js @@ -7,8 +7,6 @@ const expect = chai.expect chai.use(dirtyChai) const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() - const ipfsAPI = require('../src/index.js') function clientWorks (client, done) { @@ -28,6 +26,9 @@ describe('ipfs-api constructor tests', () => { before(function (done) { this.timeout(20 * 1000) // slow CI + + const df = DaemonFactory.create({remote: true, port: 30003}) + df.spawn((err, node) => { expect(err).to.not.exist() ipfsd = node diff --git a/test/diag.spec.js b/test/diag.spec.js index 5f68a3e95..b2312cd1e 100644 --- a/test/diag.spec.js +++ b/test/diag.spec.js @@ -10,20 +10,19 @@ const os = require('os') const IPFSApi = require('../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() 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) => { + const df = DaemonFactory.create({remote: true, port: 30003}) + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd diff --git a/test/files.spec.js b/test/files.spec.js index 3c88e26b5..5c37ae98f 100644 --- a/test/files.spec.js +++ b/test/files.spec.js @@ -14,7 +14,6 @@ const CID = require('cids') const IPFSApi = require('../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() const testfile = isNode ? loadFixture(__dirname, '/fixtures/testfile.txt') @@ -41,6 +40,8 @@ describe('.files (the MFS API part)', function () { const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' before((done) => { + const df = DaemonFactory.create({remote: true, port: 30003}) + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd diff --git a/test/interface/block.spec.js b/test/interface/block.spec.js index 5a1883088..63354de52 100644 --- a/test/interface/block.spec.js +++ b/test/interface/block.spec.js @@ -8,11 +8,12 @@ const parallel = require('async/parallel') const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() const nodes = [] const common = { setup: function (callback) { + const df = DaemonFactory.create({remote: true, port: 30003}) + callback(null, { spawnNode: (cb) => { df.spawn((err, _ipfsd) => { diff --git a/test/interface/config.spec.js b/test/interface/config.spec.js index 91f551a7d..cfe8793a5 100644 --- a/test/interface/config.spec.js +++ b/test/interface/config.spec.js @@ -8,11 +8,12 @@ const parallel = require('async/parallel') const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() const nodes = [] const common = { setup: function (callback) { + const df = DaemonFactory.create({remote: true, port: 30003}) + callback(null, { spawnNode: (cb) => { df.spawn((err, _ipfsd) => { diff --git a/test/interface/dht.spec.js b/test/interface/dht.spec.js index 1ae3081fc..e0e12458f 100644 --- a/test/interface/dht.spec.js +++ b/test/interface/dht.spec.js @@ -7,11 +7,12 @@ const parallel = require('async/parallel') const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() const nodes = [] const common = { setup: function (callback) { + const df = DaemonFactory.create({remote: true, port: 30003}) + callback(null, { spawnNode: (cb) => { df.spawn((err, _ipfsd) => { diff --git a/test/interface/files.spec.js b/test/interface/files.spec.js index c58b9d5e8..2d5536e7b 100644 --- a/test/interface/files.spec.js +++ b/test/interface/files.spec.js @@ -8,11 +8,12 @@ const parallel = require('async/parallel') const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() const nodes = [] const common = { setup: function (callback) { + const df = DaemonFactory.create({remote: true, port: 30003}) + callback(null, { spawnNode: (cb) => { df.spawn((err, _ipfsd) => { diff --git a/test/interface/key.spec.js b/test/interface/key.spec.js index 6fd3510f5..7df35900f 100644 --- a/test/interface/key.spec.js +++ b/test/interface/key.spec.js @@ -8,11 +8,12 @@ const parallel = require('async/parallel') const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() const nodes = [] const common = { setup: function (callback) { + const df = DaemonFactory.create({remote: true, port: 30003}) + callback(null, { spawnNode: (cb) => { df.spawn((err, _ipfsd) => { diff --git a/test/interface/miscellaneous.spec.js b/test/interface/miscellaneous.spec.js index f7d03f3de..b4eee65de 100644 --- a/test/interface/miscellaneous.spec.js +++ b/test/interface/miscellaneous.spec.js @@ -7,11 +7,12 @@ const test = require('interface-ipfs-core') const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() const nodes = [] const common = { setup: function (callback) { + const df = DaemonFactory.create({remote: true, port: 30003}) + callback(null, { spawnNode: (cb) => { df.spawn((err, _ipfsd) => { diff --git a/test/interface/object.spec.js b/test/interface/object.spec.js index be4ffa70c..f3a5151c9 100644 --- a/test/interface/object.spec.js +++ b/test/interface/object.spec.js @@ -8,11 +8,12 @@ const parallel = require('async/parallel') const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() const nodes = [] const common = { setup: function (callback) { + const df = DaemonFactory.create({remote: true, port: 30003}) + callback(null, { spawnNode: (cb) => { df.spawn((err, _ipfsd) => { diff --git a/test/interface/pin.spec.js b/test/interface/pin.spec.js index d72d008b3..5e538244a 100644 --- a/test/interface/pin.spec.js +++ b/test/interface/pin.spec.js @@ -8,11 +8,12 @@ const parallel = require('async/parallel') const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() const nodes = [] const common = { setup: function (callback) { + const df = DaemonFactory.create({remote: true, port: 30003}) + callback(null, { spawnNode: (cb) => { df.spawn((err, _ipfsd) => { diff --git a/test/interface/pubsub.spec.js b/test/interface/pubsub.spec.js index 4499bcbce..672a9e7d6 100644 --- a/test/interface/pubsub.spec.js +++ b/test/interface/pubsub.spec.js @@ -10,12 +10,13 @@ const parallel = require('async/parallel') const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() if (isNode) { const nodes = [] const common = { setup: function (callback) { + const df = DaemonFactory.create({remote: true, port: 30003}) + callback(null, { spawnNode: (cb) => { df.spawn({ args: ['--enable-pubsub-experiment'] }, diff --git a/test/interface/repo.spec.js b/test/interface/repo.spec.js index acce37e75..9ffd560d0 100644 --- a/test/interface/repo.spec.js +++ b/test/interface/repo.spec.js @@ -8,11 +8,12 @@ const parallel = require('async/parallel') const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() const nodes = [] const common = { setup: function (callback) { + const df = DaemonFactory.create({remote: true, port: 30003}) + callback(null, { spawnNode: (cb) => { df.spawn((err, _ipfsd) => { diff --git a/test/interface/stats.spec.js b/test/interface/stats.spec.js index 6186c33db..0fccfecb3 100644 --- a/test/interface/stats.spec.js +++ b/test/interface/stats.spec.js @@ -8,11 +8,12 @@ const parallel = require('async/parallel') const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() const nodes = [] const common = { setup: function (callback) { + const df = DaemonFactory.create({remote: true, port: 30003}) + callback(null, { spawnNode: (cb) => { df.spawn((err, _ipfsd) => { diff --git a/test/interface/swarm.spec.js b/test/interface/swarm.spec.js index 6d04fbcd8..6ff418a11 100644 --- a/test/interface/swarm.spec.js +++ b/test/interface/swarm.spec.js @@ -8,11 +8,12 @@ const parallel = require('async/parallel') const IPFSApi = require('../../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() const nodes = [] const common = { setup: function (callback) { + const df = DaemonFactory.create({remote: true, port: 30003}) + callback(null, { spawnNode: (repoPath, config, cb) => { if (typeof repoPath === 'function') { diff --git a/test/key.spec.js b/test/key.spec.js index 3db9a9953..e99c87b41 100644 --- a/test/key.spec.js +++ b/test/key.spec.js @@ -10,7 +10,6 @@ chai.use(dirtyChai) const IPFSApi = require('../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() describe('.key', function () { this.timeout(50 * 1000) @@ -19,6 +18,8 @@ describe('.key', function () { let ipfs before((done) => { + const df = DaemonFactory.create({remote: true, port: 30003}) + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd diff --git a/test/log.spec.js b/test/log.spec.js index 38dc7d710..87181af28 100644 --- a/test/log.spec.js +++ b/test/log.spec.js @@ -10,7 +10,6 @@ chai.use(dirtyChai) const IPFSApi = require('../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() describe('.log', function () { this.timeout(100 * 1000) @@ -19,6 +18,8 @@ describe('.log', function () { let ipfs before((done) => { + const df = DaemonFactory.create({remote: true, port: 30003}) + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd 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..58926aa69 100644 --- a/test/name.spec.js +++ b/test/name.spec.js @@ -14,7 +14,6 @@ const loadFixture = require('aegir/fixtures') const IPFSApi = require('../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() const testfile = isNode ? loadFixture(__dirname, '/fixtures/testfile.txt') @@ -29,6 +28,8 @@ describe('.name', function () { let otherd before((done) => { + const df = DaemonFactory.create({remote: true, port: 30003}) + series([ (cb) => { df.spawn((err, _ipfsd) => { diff --git a/test/ping.spec.js b/test/ping.spec.js index e2bcc44ff..0cb31ba20 100644 --- a/test/ping.spec.js +++ b/test/ping.spec.js @@ -12,7 +12,6 @@ const series = require('async/series') const IPFSApi = require('../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() describe.skip('.ping', () => { let ipfs @@ -22,6 +21,9 @@ describe.skip('.ping', () => { before(function (done) { this.timeout(20 * 1000) // slow CI + + const df = DaemonFactory.create({remote: true, port: 30003}) + series([ (cb) => { df.spawn((err, _ipfsd) => { diff --git a/test/pubsub-in-browser.spec.js b/test/pubsub-in-browser.spec.js index 818b477bb..391183e00 100644 --- a/test/pubsub-in-browser.spec.js +++ b/test/pubsub-in-browser.spec.js @@ -35,23 +35,21 @@ chai.use(dirtyChai) const IPFSApi = require('../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() 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) => { + const df = DaemonFactory.create({remote: true, port: 30003}) + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd diff --git a/test/refs.spec.js b/test/refs.spec.js index d6ca6572d..dccd5c582 100644 --- a/test/refs.spec.js +++ b/test/refs.spec.js @@ -13,14 +13,11 @@ const fs = require('fs') const IPFSApi = require('../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() describe('.refs', function () { this.timeout(80 * 1000) - if (!isNode) { - return - } + if (!isNode) { return } let ipfs let ipfsd @@ -38,6 +35,8 @@ describe('.refs', function () { fs.symlinkSync(symlinkTarget, symlinkPath) } + const df = DaemonFactory.create({remote: true, port: 30003}) + waterfall([ (cb) => df.spawn(cb), (_ipfsd, cb) => { diff --git a/test/repo.spec.js b/test/repo.spec.js index baf9525d9..48c401735 100644 --- a/test/repo.spec.js +++ b/test/repo.spec.js @@ -9,7 +9,6 @@ chai.use(dirtyChai) const IPFSApi = require('../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() describe('.repo', function () { this.timeout(50 * 1000) // slow CI @@ -18,6 +17,8 @@ describe('.repo', function () { let ipfsd before((done) => { + const df = DaemonFactory.create({remote: true, port: 30003}) + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd @@ -28,53 +29,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..e3340e067 100644 --- a/test/stats.spec.js +++ b/test/stats.spec.js @@ -9,7 +9,6 @@ chai.use(dirtyChai) const IPFSApi = require('../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() describe('stats', function () { this.timeout(50 * 1000) // slow CI @@ -18,6 +17,8 @@ describe('stats', function () { let ipfsd before((done) => { + const df = DaemonFactory.create({remote: true, port: 30003}) + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd 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..c82b64c1c 100644 --- a/test/util.spec.js +++ b/test/util.spec.js @@ -13,7 +13,6 @@ const fs = require('fs') const IPFSApi = require('../src') const DaemonFactory = require('ipfsd-ctl') -const df = DaemonFactory.create() describe('.util', () => { if (!isNode) { return } @@ -24,6 +23,8 @@ describe('.util', () => { before(function (done) { this.timeout(20 * 1000) // slow CI + const df = DaemonFactory.create({remote: true, port: 30003}) + df.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd From a2d34785d8d029f21e7cbd84a7ff45cca032639d Mon Sep 17 00:00:00 2001 From: David Dias Date: Sat, 10 Feb 2018 07:48:07 +0000 Subject: [PATCH 03/10] test: use the factory as a singleton --- .aegir.js | 2 +- package.json | 4 +++- test/bitswap.spec.js | 6 ++---- test/bootstrap.spec.js | 7 ++----- test/commands.spec.js | 6 ++---- test/constructor.spec.js | 6 ++---- test/diag.spec.js | 7 ++----- test/files.spec.js | 7 ++----- test/get.spec.js | 6 ++---- test/interface/block.spec.js | 7 ++----- test/interface/config.spec.js | 7 ++----- test/interface/dht.spec.js | 7 ++----- test/interface/files.spec.js | 7 ++----- test/interface/key.spec.js | 7 ++----- test/interface/miscellaneous.spec.js | 7 ++----- test/interface/object.spec.js | 7 ++----- test/interface/pin.spec.js | 7 ++----- test/interface/pubsub.spec.js | 7 ++----- test/interface/repo.spec.js | 7 ++----- test/interface/stats.spec.js | 7 ++----- test/interface/swarm.spec.js | 7 ++----- test/key.spec.js | 7 ++----- test/log.spec.js | 7 ++----- test/name.spec.js | 9 +++------ test/ping.spec.js | 9 +++------ test/pubsub-in-browser.spec.js | 7 ++----- test/refs.spec.js | 7 ++----- test/repo.spec.js | 7 ++----- test/stats.spec.js | 7 ++----- test/util.spec.js | 7 ++----- test/utils/factory.js | 3 +++ 31 files changed, 65 insertions(+), 140 deletions(-) create mode 100644 test/utils/factory.js diff --git a/.aegir.js b/.aegir.js index 1e5673304..eb52981d2 100644 --- a/.aegir.js +++ b/.aegir.js @@ -2,7 +2,7 @@ const createServer = require('ipfsd-ctl').createServer -const server = createServer(30003) +const server = createServer() module.exports = { karma: { diff --git a/package.json b/package.json index 3ab6f2812..43cf04b2f 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,9 @@ "glob": false, "fs": false, "stream": "readable-stream", - "http": "stream-http" + "http": "stream-http", + "ipfs-api": false, + "ipfs": false }, "scripts": { "test": "aegir test", diff --git a/test/bitswap.spec.js b/test/bitswap.spec.js index 4b911d6e4..8bd16f2c0 100644 --- a/test/bitswap.spec.js +++ b/test/bitswap.spec.js @@ -8,7 +8,7 @@ chai.use(dirtyChai) const IPFSApi = require('../src') -const DaemonFactory = require('ipfsd-ctl') +const f = require('./utils/factory') describe('.bitswap', function () { this.timeout(20 * 1000) // slow CI @@ -19,9 +19,7 @@ describe('.bitswap', function () { before(function (done) { this.timeout(20 * 1000) // slow CI - const df = DaemonFactory.create({remote: true, port: 30003}) - - 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 53c879951..6353c9647 100644 --- a/test/bootstrap.spec.js +++ b/test/bootstrap.spec.js @@ -8,8 +8,7 @@ const expect = chai.expect chai.use(dirtyChai) const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('./utils/factory') const invalidArg = 'this/Is/So/Invalid/' const validIp4 = '/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z' @@ -21,9 +20,7 @@ describe('.bootstrap', function () { let ipfs before((done) => { - const df = DaemonFactory.create({remote: true, port: 30003}) - - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) diff --git a/test/commands.spec.js b/test/commands.spec.js index 195f01b5c..cb69c0b8b 100644 --- a/test/commands.spec.js +++ b/test/commands.spec.js @@ -8,7 +8,7 @@ chai.use(dirtyChai) const IPFSApi = require('../src') -const DaemonFactory = require('ipfsd-ctl') +const f = require('./utils/factory') describe('.commands', function () { this.timeout(20 * 1000) @@ -17,9 +17,7 @@ describe('.commands', function () { let ipfs before((done) => { - const df = DaemonFactory.create({remote: true, port: 30003}) - - 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 5dfed1722..74042c176 100644 --- a/test/constructor.spec.js +++ b/test/constructor.spec.js @@ -6,7 +6,7 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) -const DaemonFactory = require('ipfsd-ctl') +const f = require('./utils/factory') const ipfsAPI = require('../src/index.js') function clientWorks (client, done) { @@ -27,9 +27,7 @@ describe('ipfs-api constructor tests', () => { before(function (done) { this.timeout(20 * 1000) // slow CI - const df = DaemonFactory.create({remote: true, port: 30003}) - - 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 b2312cd1e..ef2f7c605 100644 --- a/test/diag.spec.js +++ b/test/diag.spec.js @@ -8,8 +8,7 @@ chai.use(dirtyChai) const os = require('os') const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('./utils/factory') describe('.diag', function () { this.timeout(50 * 1000) @@ -21,9 +20,7 @@ describe('.diag', function () { let ipfs before((done) => { - const df = DaemonFactory.create({remote: true, port: 30003}) - - 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 5c37ae98f..5fb8bb3c3 100644 --- a/test/files.spec.js +++ b/test/files.spec.js @@ -12,8 +12,7 @@ const mh = require('multihashes') const CID = require('cids') const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('./utils/factory') const testfile = isNode ? loadFixture(__dirname, '/fixtures/testfile.txt') @@ -40,9 +39,7 @@ describe('.files (the MFS API part)', function () { const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' before((done) => { - const df = DaemonFactory.create({remote: true, port: 30003}) - - 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 63354de52..b7b4181cf 100644 --- a/test/interface/block.spec.js +++ b/test/interface/block.spec.js @@ -6,17 +6,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { - const df = DaemonFactory.create({remote: true, port: 30003}) - 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 cfe8793a5..0c47b099b 100644 --- a/test/interface/config.spec.js +++ b/test/interface/config.spec.js @@ -6,17 +6,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { - const df = DaemonFactory.create({remote: true, port: 30003}) - 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 e0e12458f..4e02d8343 100644 --- a/test/interface/dht.spec.js +++ b/test/interface/dht.spec.js @@ -5,17 +5,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { - const df = DaemonFactory.create({remote: true, port: 30003}) - 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 2d5536e7b..2b464be20 100644 --- a/test/interface/files.spec.js +++ b/test/interface/files.spec.js @@ -6,17 +6,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { - const df = DaemonFactory.create({remote: true, port: 30003}) - 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 7df35900f..b34221f70 100644 --- a/test/interface/key.spec.js +++ b/test/interface/key.spec.js @@ -6,17 +6,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { - const df = DaemonFactory.create({remote: true, port: 30003}) - 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 b4eee65de..1d203604e 100644 --- a/test/interface/miscellaneous.spec.js +++ b/test/interface/miscellaneous.spec.js @@ -5,17 +5,14 @@ const test = require('interface-ipfs-core') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { - const df = DaemonFactory.create({remote: true, port: 30003}) - 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 f3a5151c9..bdc74e227 100644 --- a/test/interface/object.spec.js +++ b/test/interface/object.spec.js @@ -6,17 +6,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { - const df = DaemonFactory.create({remote: true, port: 30003}) - 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 5e538244a..dd7891461 100644 --- a/test/interface/pin.spec.js +++ b/test/interface/pin.spec.js @@ -6,17 +6,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { - const df = DaemonFactory.create({remote: true, port: 30003}) - 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 672a9e7d6..ddba34e2a 100644 --- a/test/interface/pubsub.spec.js +++ b/test/interface/pubsub.spec.js @@ -8,18 +8,15 @@ const isNode = require('detect-node') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('../utils/factory') if (isNode) { const nodes = [] const common = { setup: function (callback) { - const df = DaemonFactory.create({remote: true, port: 30003}) - 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 9ffd560d0..211f8bb41 100644 --- a/test/interface/repo.spec.js +++ b/test/interface/repo.spec.js @@ -6,17 +6,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { - const df = DaemonFactory.create({remote: true, port: 30003}) - 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 0fccfecb3..1a2a9aa15 100644 --- a/test/interface/stats.spec.js +++ b/test/interface/stats.spec.js @@ -6,17 +6,14 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { - const df = DaemonFactory.create({remote: true, port: 30003}) - 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 6ff418a11..735f60d95 100644 --- a/test/interface/swarm.spec.js +++ b/test/interface/swarm.spec.js @@ -6,14 +6,11 @@ const test = require('interface-ipfs-core') const parallel = require('async/parallel') const IPFSApi = require('../../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('../utils/factory') const nodes = [] const common = { setup: function (callback) { - const df = DaemonFactory.create({remote: true, port: 30003}) - callback(null, { spawnNode: (repoPath, config, cb) => { if (typeof repoPath === 'function') { @@ -26,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 e99c87b41..5d958708f 100644 --- a/test/key.spec.js +++ b/test/key.spec.js @@ -8,8 +8,7 @@ const expect = chai.expect chai.use(dirtyChai) const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('./utils/factory') describe('.key', function () { this.timeout(50 * 1000) @@ -18,9 +17,7 @@ describe('.key', function () { let ipfs before((done) => { - const df = DaemonFactory.create({remote: true, port: 30003}) - - 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 87181af28..1d9d98659 100644 --- a/test/log.spec.js +++ b/test/log.spec.js @@ -8,8 +8,7 @@ const expect = chai.expect chai.use(dirtyChai) const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('./utils/factory') describe('.log', function () { this.timeout(100 * 1000) @@ -18,9 +17,7 @@ describe('.log', function () { let ipfs before((done) => { - const df = DaemonFactory.create({remote: true, port: 30003}) - - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) diff --git a/test/name.spec.js b/test/name.spec.js index 58926aa69..fba5ba01c 100644 --- a/test/name.spec.js +++ b/test/name.spec.js @@ -12,8 +12,7 @@ const series = require('async/series') const loadFixture = require('aegir/fixtures') const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('./utils/factory') const testfile = isNode ? loadFixture(__dirname, '/fixtures/testfile.txt') @@ -28,11 +27,9 @@ describe('.name', function () { let otherd before((done) => { - const df = DaemonFactory.create({remote: true, port: 30003}) - series([ (cb) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) @@ -40,7 +37,7 @@ describe('.name', function () { }) }, (cb) => { - df.spawn((err, node) => { + f.spawn((err, node) => { expect(err).to.not.exist() other = node.api otherd = node diff --git a/test/ping.spec.js b/test/ping.spec.js index 0cb31ba20..c39673615 100644 --- a/test/ping.spec.js +++ b/test/ping.spec.js @@ -10,8 +10,7 @@ const parallel = require('async/parallel') const series = require('async/series') const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('./utils/factory') describe.skip('.ping', () => { let ipfs @@ -22,11 +21,9 @@ describe.skip('.ping', () => { before(function (done) { this.timeout(20 * 1000) // slow CI - const df = DaemonFactory.create({remote: true, port: 30003}) - series([ (cb) => { - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) @@ -35,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 391183e00..95070e459 100644 --- a/test/pubsub-in-browser.spec.js +++ b/test/pubsub-in-browser.spec.js @@ -33,8 +33,7 @@ const expect = chai.expect chai.use(dirtyChai) const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('./utils/factory') const expectedError = 'pubsub is currently not supported when run in the browser' @@ -48,9 +47,7 @@ describe('.pubsub is not supported in the browser, yet!', function () { let ipfsd before((done) => { - const df = DaemonFactory.create({remote: true, port: 30003}) - - 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 dccd5c582..d74717597 100644 --- a/test/refs.spec.js +++ b/test/refs.spec.js @@ -11,8 +11,7 @@ const path = require('path') const fs = require('fs') const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('./utils/factory') describe('.refs', function () { this.timeout(80 * 1000) @@ -35,10 +34,8 @@ describe('.refs', function () { fs.symlinkSync(symlinkTarget, symlinkPath) } - const df = DaemonFactory.create({remote: true, port: 30003}) - 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 48c401735..ee3f7f0b6 100644 --- a/test/repo.spec.js +++ b/test/repo.spec.js @@ -7,8 +7,7 @@ const expect = chai.expect chai.use(dirtyChai) const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('./utils/factory') describe('.repo', function () { this.timeout(50 * 1000) // slow CI @@ -17,9 +16,7 @@ describe('.repo', function () { let ipfsd before((done) => { - const df = DaemonFactory.create({remote: true, port: 30003}) - - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) diff --git a/test/stats.spec.js b/test/stats.spec.js index e3340e067..73cd29774 100644 --- a/test/stats.spec.js +++ b/test/stats.spec.js @@ -7,8 +7,7 @@ const expect = chai.expect chai.use(dirtyChai) const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('./utils/factory') describe('stats', function () { this.timeout(50 * 1000) // slow CI @@ -17,9 +16,7 @@ describe('stats', function () { let ipfsd before((done) => { - const df = DaemonFactory.create({remote: true, port: 30003}) - - df.spawn((err, _ipfsd) => { + f.spawn((err, _ipfsd) => { expect(err).to.not.exist() ipfsd = _ipfsd ipfs = IPFSApi(_ipfsd.apiAddr) diff --git a/test/util.spec.js b/test/util.spec.js index c82b64c1c..1573620fd 100644 --- a/test/util.spec.js +++ b/test/util.spec.js @@ -11,8 +11,7 @@ const path = require('path') const fs = require('fs') const IPFSApi = require('../src') - -const DaemonFactory = require('ipfsd-ctl') +const f = require('./utils/factory') describe('.util', () => { if (!isNode) { return } @@ -23,9 +22,7 @@ describe('.util', () => { before(function (done) { this.timeout(20 * 1000) // slow CI - const df = DaemonFactory.create({remote: true, port: 30003}) - - 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() From 849f70266532f73e1d5fde6fecfa57520fcefd4f Mon Sep 17 00:00:00 2001 From: David Dias Date: Sat, 10 Feb 2018 08:18:17 +0000 Subject: [PATCH 04/10] still no luck --- package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 43cf04b2f..4acb8da7c 100644 --- a/package.json +++ b/package.json @@ -9,12 +9,14 @@ "stream": "readable-stream", "http": "stream-http", "ipfs-api": false, - "ipfs": false + "ipfs": false, + "./node_modules/ipfsd-ctl/src/ipfsd-in-proc.js": false, + "./node_modules/ipfsd-ctl/src/factory-in-proc.js": false }, "scripts": { "test": "aegir test", "test:node": "aegir test -t node", - "test:browser": "aegir test -t browser", + "test:browser": "node --max-old-space-size=8192 ./node_modules/.bin/aegir test -t browser", "test:webworker": "aegir test -t webworker", "lint": "aegir lint", "build": "aegir build", From b1e0cd69362a40de7af77fdec235303652ecc3bc Mon Sep 17 00:00:00 2001 From: David Dias Date: Sat, 10 Feb 2018 08:24:21 +0000 Subject: [PATCH 05/10] not my happy solution --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 4acb8da7c..e1714f497 100644 --- a/package.json +++ b/package.json @@ -16,15 +16,15 @@ "scripts": { "test": "aegir test", "test:node": "aegir test -t node", - "test:browser": "node --max-old-space-size=8192 ./node_modules/.bin/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", From 914d3b0986a0edec086de066d829de7d6458d346 Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 12 Feb 2018 09:11:20 +0000 Subject: [PATCH 06/10] test: update name test --- test/name.spec.js | 77 +++++++++++++++++------------------------------ 1 file changed, 27 insertions(+), 50 deletions(-) diff --git a/test/name.spec.js b/test/name.spec.js index fba5ba01c..bffe573c4 100644 --- a/test/name.spec.js +++ b/test/name.spec.js @@ -18,15 +18,16 @@ 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) => { f.spawn((err, _ipfsd) => { @@ -61,60 +62,36 @@ describe('.name', function () { ], done) }) - describe('Callback API', () => { - let name - - 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() - }) - }) + it('add file for testing', (done) => { + const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' - 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() - }) - }) + ipfs.files.add(testfile, (err, res) => { + expect(err).to.not.exist() - 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() }) }) }) From 70fd29e28862a54b16bb90645cb8105244f4d4c1 Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 12 Feb 2018 09:22:45 +0000 Subject: [PATCH 07/10] avoid dup tests --- test/bootstrap.spec.js | 198 ++++++++++++----------------------------- test/log.spec.js | 79 +++++----------- 2 files changed, 76 insertions(+), 201 deletions(-) diff --git a/test/bootstrap.spec.js b/test/bootstrap.spec.js index 6353c9647..8a32d5274 100644 --- a/test/bootstrap.spec.js +++ b/test/bootstrap.spec.js @@ -32,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/log.spec.js b/test/log.spec.js index 1d9d98659..4c780e37d 100644 --- a/test/log.spec.js +++ b/test/log.spec.js @@ -27,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() }) }) }) From bb505859df9c7a1d8f603ed1a7da5cffecf67bfe Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 12 Feb 2018 12:17:10 +0000 Subject: [PATCH 08/10] chore: update deps --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index e1714f497..a6e8dfb5b 100644 --- a/package.json +++ b/package.json @@ -45,14 +45,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", @@ -75,7 +75,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", From 6f6cd845ca8d43b7ccabcfeaf0d39c7200f5a832 Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 12 Feb 2018 12:20:33 +0000 Subject: [PATCH 09/10] chore: update package.json --- package.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/package.json b/package.json index a6e8dfb5b..0e713105c 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,7 @@ "glob": false, "fs": false, "stream": "readable-stream", - "http": "stream-http", - "ipfs-api": false, - "ipfs": false, - "./node_modules/ipfsd-ctl/src/ipfsd-in-proc.js": false, - "./node_modules/ipfsd-ctl/src/factory-in-proc.js": false + "http": "stream-http" }, "scripts": { "test": "aegir test", From 66e49c0f0ff3bfd0ccb6e9fbff0878552624aa01 Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 12 Feb 2018 12:27:35 +0000 Subject: [PATCH 10/10] avoid bundling repeated ipfs-api --- package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 0e713105c..d94270103 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,9 @@ "glob": false, "fs": false, "stream": "readable-stream", - "http": "stream-http" + "http": "stream-http", + "ipfs-api": false, + "ipfs": false }, "scripts": { "test": "aegir test",