diff --git a/.aegir.js b/.aegir.js index 148ab3fbb8..6a0af49287 100644 --- a/.aegir.js +++ b/.aegir.js @@ -1,41 +1,23 @@ 'use strict' -const parallel = require('async/parallel') -const ads = require('./test/utils/another-daemon-spawner') -const js = ads.spawnJsNode -const stop = ads.stopNodes - -/* - * spawns a daemon with ports numbers starting in 10 and ending in `num` - */ -function start (done) { - const base = '/ip4/127.0.0.1/tcp' - if (!process.env.IPFS_TEST) { - parallel([ - (cb) => js([`${base}/10007`, `${base}/20007/ws`], true, 31007, 32007, cb), - (cb) => js([`${base}/10008`, `${base}/20008/ws`], true, 31008, 32008, cb), - (cb) => js([`${base}/10012`, `${base}/20012/ws`], true, 31012, 32012, cb), - (cb) => js([`${base}/10013`, `${base}/20013/ws`], true, 31013, 32013, cb), - (cb) => js([`${base}/10014`, `${base}/20014/ws`], true, 31014, 32014, cb), - (cb) => js([`${base}/10015`, `${base}/20015/ws`], true, 31015, 32015, cb) - ], done) - } else if (process.env.IPFS_TEST === 'bootstrapers') { - done() - } -} +const createServer = require('ipfsd-ctl').createServer +const server = createServer() module.exports = { karma: { files: [{ pattern: 'node_modules/interface-ipfs-core/test/fixtures/**/*', watched: false, served: true, - included: false, - singleRun: false - }] + included: false + }], + browserNoActivityTimeout: 100 * 1000, + singleRun: true }, hooks: { - pre: start, - post: stop + browser: { + pre: server.start.bind(server), + post: server.stop.bind(server) + } } } diff --git a/package.json b/package.json index 0996573523..dc7d2a1519 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "build": "aegir build", "test": "aegir test -t node -t browser -t webworker --no-cors", "test:node": "aegir test -t node", - "test:browser": "aegir test -t browser -t webworker --no-cors", + "test:browser": "aegir test -t browser --no-cors", + "test:webworker": "aegir test -t webworker --no-cors", "test:node:core": "aegir test -t node -f test/core/**.js", "test:node:http": "aegir test -t node -f test/http-api/index.js", "test:node:gateway": "aegir test -t node -f test/gateway/index.js", @@ -70,8 +71,10 @@ "execa": "^0.9.0", "expose-loader": "^0.7.4", "form-data": "^2.3.1", + "go-ipfs-dep": "^0.4.13", "hat": "0.0.3", - "interface-ipfs-core": "~0.40.0", + "interface-ipfs-core": "~0.41.0", + "ipfsd-ctl": "^0.27.0", "left-pad": "^1.2.0", "lodash": "^4.17.4", "mocha": "^4.1.0", diff --git a/test/cli/pubsub.js b/test/cli/pubsub.js index 3df5bf8417..8bf14731fa 100644 --- a/test/cli/pubsub.js +++ b/test/cli/pubsub.js @@ -8,16 +8,28 @@ const expect = chai.expect chai.use(dirtyChai) const delay = require('delay') const series = require('async/series') -const InstanceFactory = require('../utils/ipfs-factory-instance') -const DaemonFactory = require('../utils/ipfs-factory-daemon') const ipfsExec = require('../utils/ipfs-exec') +const IPFS = require('../../src') + +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ type: 'js' }) + +const config = { + Bootstrap: [], + Discovery: { + MDNS: { + Enabled: + false + } + } +} describe('pubsub', function () { - this.timeout(40 * 1000) + this.timeout(80 * 1000) - let instanceFactory - let daemonFactory let node + let ipfsdA + let ipfsdB let cli let httpApi @@ -28,26 +40,38 @@ describe('pubsub', function () { before(function (done) { this.timeout(60 * 1000) - instanceFactory = new InstanceFactory() - instanceFactory.spawnNode((err, _node) => { - expect(err).to.not.exist() - node = _node - done() - }) + DaemonFactory + .create({ type: 'proc' }) + .spawn({ + exec: IPFS, + config, + args: ['--enable-pubsub-experiment'] + }, (err, _ipfsd) => { + expect(err).to.not.exist() + ipfsdA = _ipfsd + node = _ipfsd.api + done() + }) }) - after((done) => instanceFactory.dismantle(done)) + after((done) => ipfsdB.stop(done)) before((done) => { - daemonFactory = new DaemonFactory() - daemonFactory.spawnNode((err, _node) => { + df.spawn({ + args: ['--enable-pubsub-experiment'], + exec: `./src/cli/bin.js`, + config + }, (err, _ipfsd) => { expect(err).to.not.exist() - httpApi = _node + httpApi = _ipfsd.api + ipfsdB = _ipfsd + httpApi.repoPath = ipfsdB.repoPath done() }) }) - after((done) => daemonFactory.dismantle(done)) + after((done) => ipfsdA.stop(done)) + after((done) => ipfsdB.stop(done)) before((done) => { cli = ipfsExec(httpApi.repoPath) diff --git a/test/cli/swarm.js b/test/cli/swarm.js index d2c69846be..424734c194 100644 --- a/test/cli/swarm.js +++ b/test/cli/swarm.js @@ -8,34 +8,48 @@ const expect = chai.expect chai.use(dirtyChai) const series = require('async/series') const ipfsExec = require('../utils/ipfs-exec') -const Factory = require('../utils/ipfs-factory-daemon') + +const parallel = require('async/parallel') + +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ type: 'js' }) + +const config = { + Bootstrap: [], + Discovery: { + MDNS: { + Enabled: + false + } + } +} describe('swarm', () => { - let factory let bMultiaddr let ipfsA + let nodes = [] before(function (done) { // CI takes longer to instantiate the daemon, so we need to increase the // timeout for the before step this.timeout(80 * 1000) - factory = new Factory() - series([ (cb) => { - factory.spawnNode((err, node) => { + df.spawn({ exec: `./src/cli/bin.js`, config }, (err, node) => { expect(err).to.not.exist() ipfsA = ipfsExec(node.repoPath) + nodes.push(node) cb() }) }, (cb) => { - factory.spawnNode((err, node) => { + df.spawn({ exec: `./src/cli/bin.js`, config }, (err, node) => { expect(err).to.not.exist() - node.id((err, id) => { + node.api.id((err, id) => { expect(err).to.not.exist() bMultiaddr = id.addresses[0] + nodes.push(node) cb() }) }) @@ -43,7 +57,7 @@ describe('swarm', () => { ], done) }) - after((done) => factory.dismantle(done)) + after((done) => parallel(nodes.map((node) => (cb) => node.stop(cb)), done)) describe('daemon on (through http-api)', function () { this.timeout(60 * 1000) diff --git a/test/core/bitswap.spec.js b/test/core/bitswap.spec.js index 2dffff99bc..b06b4c41f8 100644 --- a/test/core/bitswap.spec.js +++ b/test/core/bitswap.spec.js @@ -10,14 +10,17 @@ const _ = require('lodash') const series = require('async/series') const waterfall = require('async/waterfall') const parallel = require('async/parallel') -const leftPad = require('left-pad') const Block = require('ipfs-block') -const API = require('ipfs-api') const multiaddr = require('multiaddr') const isNode = require('detect-node') const multihashing = require('multihashing-async') const CID = require('cids') +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ type: 'js' }) + +const dfProc = DaemonFactory.create({ type: 'proc' }) + // This gets replaced by '../utils/create-repo-browser.js' in the browser const createTempRepo = require('../utils/create-repo-nodejs.js') @@ -63,13 +66,27 @@ function connectNodes (remoteNode, inProcNode, callback) { ], callback) } -function addNode (num, inProcNode, callback) { - num = leftPad(num, 3, 0) - - const apiUrl = `/ip4/127.0.0.1/tcp/31${num}` - const remoteNode = new API(apiUrl) - - connectNodes(remoteNode, inProcNode, (err) => callback(err, remoteNode)) +let nodes = [] + +function addNode (inProcNode, callback) { + df.spawn({ + exec: `./src/cli/bin.js`, + config: { + Addresses: { + Swarm: [`/ip4/127.0.0.1/tcp/0/ws`] + }, + Discovery: { + MDNS: { + Enabled: false + } + }, + Bootstrap: [] + } + }, (err, ipfsd) => { + expect(err).to.not.exist() + nodes.push(ipfsd) + connectNodes(ipfsd.api, inProcNode, (err) => callback(err, ipfsd.api)) + }) } describe('bitswap', function () { @@ -80,23 +97,20 @@ describe('bitswap', function () { beforeEach(function (done) { this.timeout(60 * 1000) - let options = { - repo: createTempRepo(), - config: { - Addresses: { - Swarm: [] - }, - Discovery: { - MDNS: { - Enabled: false - } - }, - Bootstrap: [] - } + let config = { + Addresses: { + Swarm: [] + }, + Discovery: { + MDNS: { + Enabled: false + } + }, + Bootstrap: [] } if (isNode) { - options = Object.assign(options, { + config = Object.assign({}, config, { config: { Addresses: { Swarm: ['/ip4/127.0.0.1/tcp/0'] @@ -105,25 +119,34 @@ describe('bitswap', function () { }) } - inProcNode = new IPFS(options) - inProcNode.on('ready', () => done()) + dfProc.spawn({ exec: IPFS, config }, (err, _ipfsd) => { + expect(err).to.not.exist() + nodes.push(_ipfsd) + inProcNode = _ipfsd.api + done() + }) }) afterEach(function (done) { - this.timeout(60 * 1000) - setTimeout(() => inProcNode.stop(() => done()), 500) + this.timeout(80 * 1000) + const tasks = nodes.map((node) => (cb) => node.stop(cb)) + parallel(tasks, (err) => { + expect(err).to.not.exist() + nodes = [] + done() + }) }) describe('transfer a block between', () => { it('2 peers', function (done) { - this.timeout(40 * 1000) + this.timeout(80 * 1000) let remoteNode let block waterfall([ (cb) => parallel([ (cb) => makeBlock(cb), - (cb) => addNode(13, inProcNode, cb) + (cb) => addNode(inProcNode, cb) ], cb), (res, cb) => { block = res[0] @@ -140,7 +163,7 @@ describe('bitswap', function () { }) it('3 peers', function (done) { - this.timeout(60 * 1000) + this.timeout(80 * 1000) let blocks const remoteNodes = [] @@ -151,11 +174,11 @@ describe('bitswap', function () { blocks = _blocks cb() }), - (cb) => addNode(8, inProcNode, (err, _ipfs) => { + (cb) => addNode(inProcNode, (err, _ipfs) => { remoteNodes.push(_ipfs) cb(err) }), - (cb) => addNode(7, inProcNode, (err, _ipfs) => { + (cb) => addNode(inProcNode, (err, _ipfs) => { remoteNodes.push(_ipfs) cb(err) }), @@ -193,10 +216,10 @@ describe('bitswap', function () { waterfall([ // 0. Start node - (cb) => addNode(12, inProcNode, cb), + (cb) => addNode(inProcNode, cb), // 1. Add file to tmp instance (remote, cb) => { - remote.files.add([{path: 'awesome.txt', content: file}], cb) + remote.files.add([{ path: 'awesome.txt', content: file }], cb) }, // 2. Request file from local instance (filesAdded, cb) => inProcNode.files.cat(filesAdded[0].hash, cb) @@ -247,7 +270,7 @@ describe('bitswap', function () { describe('while online', () => { before(function (done) { - this.timeout(40 * 1000) + this.timeout(80 * 1000) node.start(() => done()) }) diff --git a/test/core/bootstrap.spec.js b/test/core/bootstrap.spec.js index 3f291c5696..6abe498cf2 100644 --- a/test/core/bootstrap.spec.js +++ b/test/core/bootstrap.spec.js @@ -7,42 +7,37 @@ const expect = chai.expect chai.use(dirtyChai) const isNode = require('detect-node') +const IPFS = require('../../src') -// This gets replaced by `create-repo-browser.js` in the browser -const createTempRepo = require('../utils/create-repo-nodejs.js') - -const IPFS = require('../../src/core') +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ type: 'proc' }) describe('bootstrap', () => { - if (!isNode) { return } + if (!isNode) { + return + } let node + let ipfsd before(function (done) { this.timeout(40 * 1000) - node = new IPFS({ - repo: createTempRepo(), - init: { - bits: 1024 - }, - EXPERIMENTAL: { - pubsub: true - }, + df.spawn({ + exec: IPFS, config: { Addresses: { Swarm: ['/ip4/127.0.0.1/tcp/0'] } } - }) - - node.on('error', (err) => { + }, (err, _ipfsd) => { expect(err).to.not.exist() + ipfsd = _ipfsd + node = _ipfsd.api + done() }) - - node.on('start', done) }) - after((done) => node.stop(done)) + after((done) => ipfsd.stop(done)) const defaultList = [ '/ip4/104.131.131.82/tcp/4001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ', @@ -80,7 +75,7 @@ describe('bootstrap', () => { it('add a peer to the bootstrap list', (done) => { node.bootstrap.add('/ip4/111.111.111.111/tcp/1001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLUVIT', (err, res) => { expect(err).to.not.exist() - expect(res).to.be.eql({Peers: ['/ip4/111.111.111.111/tcp/1001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLUVIT']}) + expect(res).to.be.eql({ Peers: ['/ip4/111.111.111.111/tcp/1001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLUVIT'] }) node.bootstrap.list((err, list) => { expect(err).to.not.exist() expect(list.Peers).to.deep.equal(updatedList) @@ -92,7 +87,7 @@ describe('bootstrap', () => { it('remove a peer from the bootstrap list', (done) => { node.bootstrap.rm('/ip4/111.111.111.111/tcp/1001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLUVIT', (err, res) => { expect(err).to.not.exist() - expect(res).to.be.eql({Peers: ['/ip4/111.111.111.111/tcp/1001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLUVIT']}) + expect(res).to.be.eql({ Peers: ['/ip4/111.111.111.111/tcp/1001/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLUVIT'] }) node.bootstrap.list((err, list) => { expect(err).to.not.exist() expect(list.Peers).to.deep.equal(defaultList) diff --git a/test/core/circuit-relay.spec.js b/test/core/circuit-relay.spec.js deleted file mode 100644 index 4934b5cadb..0000000000 --- a/test/core/circuit-relay.spec.js +++ /dev/null @@ -1,145 +0,0 @@ -/* eslint max-nested-callbacks: ["error", 8] */ -/* eslint-env mocha */ -'use strict' - -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const expect = chai.expect -chai.use(dirtyChai) -const parallel = require('async/parallel') -const series = require('async/series') -const waterfall = require('async/waterfall') -const API = require('ipfs-api') -const bl = require('bl') -const PeerInfo = require('peer-info') -const PeerId = require('peer-id') -const multiaddr = require('multiaddr') -const isNode = require('detect-node') -const crypto = require('crypto') -const IPFSFactory = require('../utils/ipfs-factory-instance') - -function peerInfoFromObj (obj, callback) { - waterfall([ - (cb) => PeerInfo.create(PeerId.createFromB58String(obj.id), cb), - (peer, cb) => { - obj.addresses.forEach((a) => peer.multiaddrs.add(multiaddr(a))) - cb(null, peer) - } - ], callback) -} - -describe.skip('circuit', function () { - this.timeout(40 * 1000) - - let factory - - let jsRelay = new API(`/ip4/127.0.0.1/tcp/31015`) - // let goRelay = new API(`/ip4/127.0.0.1/tcp/33031`) - let node1 - let node2 - - let jsRelayId - let goRelayId - - // let nodeId1 - let nodeId2 - - before(function (done) { - this.timeout(40 * 1000) - - factory = new IPFSFactory() - - const base = { - EXPERIMENTAL: { - Relay: { - Enabled: true - } - }, - Addresses: { - Swarm: [] - } - } - - parallel([ - (cb) => factory.spawnNode(null, Object.assign(base, { - Addresses: { - Swarm: [ (isNode ? `/ip4/127.0.0.1/tcp/0` : '') ] - } - }), cb), - (cb) => factory.spawnNode(null, Object.assign(base, { - Addresses: { - Swarm: [ (isNode ? `/ip4/127.0.0.1/tcp/0/ws` : '') ] - } - }), cb) - ], (err, nodes) => { - expect(err).to.not.exist() - node1 = nodes[0] - node2 = nodes[1] - - parallel([ - (cb) => jsRelay.id(cb), - // (cb) => goRelay.id(cb), - (cb) => node1.id(cb), - (cb) => node2.id(cb) - ], (err, res2) => { - expect(err).to.not.exist() - parallel([ - (cb) => peerInfoFromObj(res2[0], cb), - // (cb) => peerInfoFromObj(res2[1], cb), - (cb) => peerInfoFromObj(res2[1], cb), - (cb) => peerInfoFromObj(res2[2], cb) - ], (err, res3) => { - expect(err).to.not.exist() - jsRelayId = res3[0] - // goRelayId = res3[1] - // nodeId1 = res3[2] - nodeId2 = res3[2] - done() - }) - }) - }) - }) - - after((done) => factory.dismantle(done)) - - // TODO: 1) figure out why this test hangs randomly - // TODO: 2) move this test to the interop batch - it.skip('node1 <-> goRelay <-> node2', (done) => { - const data = crypto.randomBytes(128) - - series([ - (cb) => node1.swarm.connect(goRelayId, cb), - (cb) => setTimeout(cb, 1000), - (cb) => node2.swarm.connect(goRelayId, cb), - (cb) => setTimeout(cb, 1000), - (cb) => node1.swarm.connect(nodeId2, cb) - ], (err) => { - expect(err).to.not.exist() - waterfall([ - (cb) => node1.files.add(data, cb), - (filesAdded, cb) => node2.files.cat(filesAdded[0].hash, cb), - (stream, cb) => stream.pipe(bl(cb)) - ], done) - }) - }) - - it('node1 <-> jsRelay <-> node2', (done) => { - const data = crypto.randomBytes(128) - - series([ - (cb) => node1.swarm.connect(jsRelayId, cb), - (cb) => setTimeout(cb, 1000), - (cb) => node2.swarm.connect(jsRelayId, cb), - (cb) => setTimeout(cb, 1000), - (cb) => node1.swarm.connect(nodeId2, cb) - ], (err) => { - expect(err).to.not.exist() - - waterfall([ - (cb) => node1.files.add(data, cb), - (filesAdded, cb) => node2.files.cat(filesAdded[0].hash, cb), - (stream, cb) => stream.pipe(bl(cb)) - ], done) - }) - }) -}) diff --git a/test/core/files-sharding.spec.js b/test/core/files-sharding.spec.js index aaf97c8b64..156dbf4442 100644 --- a/test/core/files-sharding.spec.js +++ b/test/core/files-sharding.spec.js @@ -9,7 +9,9 @@ chai.use(dirtyChai) const pull = require('pull-stream') const IPFS = require('../../src/core') -const createTempRepo = require('../utils/create-repo-nodejs.js') + +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ type: 'proc' }) describe('files directory (sharding tests)', () => { function createTestFiles () { @@ -27,12 +29,13 @@ describe('files directory (sharding tests)', () => { describe('without sharding', () => { let ipfs + let ipfsd before(function (done) { this.timeout(40 * 1000) - ipfs = new IPFS({ - repo: createTempRepo(), + df.spawn({ + exec: IPFS, config: { Addresses: { Swarm: [] @@ -44,13 +47,17 @@ describe('files directory (sharding tests)', () => { } } } + }, (err, _ipfsd) => { + expect(err).to.not.exist() + ipfsd = _ipfsd + ipfs = _ipfsd.api + done() }) - ipfs.once('ready', done) }) after(function (done) { this.timeout(40 * 1000) - ipfs.stop(done) + ipfsd.stop(done) }) it('should be able to add dir without sharding', function (done) { @@ -72,12 +79,14 @@ describe('files directory (sharding tests)', () => { describe('with sharding', () => { let ipfs + let ipfsd before(function (done) { this.timeout(40 * 1000) - ipfs = new IPFS({ - repo: createTempRepo(), + df.spawn({ + exec: IPFS, + args: ['--enable-sharding-experiment'], config: { Addresses: { Swarm: [] @@ -88,17 +97,18 @@ describe('files directory (sharding tests)', () => { Enabled: false } } - }, - EXPERIMENTAL: { - sharding: true } + }, (err, _ipfsd) => { + expect(err).to.not.exist() + ipfsd = _ipfsd + ipfs = _ipfsd.api + done() }) - ipfs.once('ready', done) }) after(function (done) { this.timeout(40 * 1000) - ipfs.stop(done) + ipfsd.stop(done) }) it('should be able to add dir with sharding', function (done) { diff --git a/test/core/interface/block.js b/test/core/interface/block.js index fafb7f7e70..5246ce3734 100644 --- a/test/core/interface/block.js +++ b/test/core/interface/block.js @@ -2,17 +2,31 @@ 'use strict' const test = require('interface-ipfs-core') -const IPFSFactory = require('../../utils/ipfs-factory-instance') +const parallel = require('async/parallel') -let factory +const IPFS = require('../../../src') +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ type: 'proc', exec: IPFS }) + +const nodes = [] const common = { - setup: function (cb) { - factory = new IPFSFactory() - cb(null, factory) + setup: function (callback) { + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, _ipfsd.api) + }) + } + }) }, - teardown: function (cb) { - factory.dismantle(cb) + teardown: function (callback) { + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/core/interface/config.js b/test/core/interface/config.js index 80b0c76d9e..1408e2281f 100644 --- a/test/core/interface/config.js +++ b/test/core/interface/config.js @@ -1,19 +1,32 @@ /* eslint-env mocha */ - 'use strict' const test = require('interface-ipfs-core') -const IPFSFactory = require('../../utils/ipfs-factory-instance') +const parallel = require('async/parallel') + +const IPFS = require('../../../src') -let factory +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ type: 'proc', exec: IPFS }) +const nodes = [] const common = { - setup: function (cb) { - factory = new IPFSFactory() - cb(null, factory) + setup: function (callback) { + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, _ipfsd.api) + }) + } + }) }, - teardown: function (cb) { - factory.dismantle(cb) + teardown: function (callback) { + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/core/interface/dag.js b/test/core/interface/dag.js index cab259b00a..4e384cb105 100644 --- a/test/core/interface/dag.js +++ b/test/core/interface/dag.js @@ -1,19 +1,32 @@ /* eslint-env mocha */ - 'use strict' const test = require('interface-ipfs-core') -const IPFSFactory = require('../../utils/ipfs-factory-instance') +const parallel = require('async/parallel') + +const IPFS = require('../../../src') -let factory +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ type: 'proc', exec: IPFS }) +const nodes = [] const common = { - setup: function (cb) { - factory = new IPFSFactory() - cb(null, factory) + setup: function (callback) { + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, _ipfsd.api) + }) + } + }) }, - teardown: function (cb) { - factory.dismantle(cb) + teardown: function (callback) { + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/core/interface/dht.js b/test/core/interface/dht.js index 28e6bb7658..532f3f4829 100644 --- a/test/core/interface/dht.js +++ b/test/core/interface/dht.js @@ -1,22 +1,32 @@ /* eslint-env mocha */ - 'use strict' /* const test = require('interface-ipfs-core') -const IPFSFactory = require('../../utils/ipfs-factory-instance') +const parallel = require('async/parallel') -let factory +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ type: 'proc', exec: IPFS }) +const nodes = [] const common = { setup: function (callback) { - factory = new IPFSFactory() - callback(null, factory) + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, _ipfsd.api) + }) + } + }) }, teardown: function (callback) { - factory.dismantle(callback) + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } - test.dht(common) */ diff --git a/test/core/interface/files.js b/test/core/interface/files.js index 5c7c7f391c..29fc97c530 100644 --- a/test/core/interface/files.js +++ b/test/core/interface/files.js @@ -2,17 +2,31 @@ 'use strict' const test = require('interface-ipfs-core') -const IPFSFactory = require('../../utils/ipfs-factory-instance') +const parallel = require('async/parallel') -let factory +const IPFS = require('../../../src') +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ type: 'proc', exec: IPFS }) + +const nodes = [] const common = { - setup: function (cb) { - factory = new IPFSFactory() - cb(null, factory) + setup: function (callback) { + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, _ipfsd.api) + }) + } + }) }, - teardown: function (cb) { - factory.dismantle(cb) + teardown: function (callback) { + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/core/interface/generic.js b/test/core/interface/generic.js index d2c8825a11..9af526e58b 100644 --- a/test/core/interface/generic.js +++ b/test/core/interface/generic.js @@ -1,19 +1,32 @@ /* eslint-env mocha */ - 'use strict' const test = require('interface-ipfs-core') -const IPFSFactory = require('../../utils/ipfs-factory-instance') +const parallel = require('async/parallel') + +const IPFS = require('../../../src') -let factory +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ type: 'proc', exec: IPFS }) +const nodes = [] const common = { - setup: function (cb) { - factory = new IPFSFactory() - cb(null, factory) + setup: function (callback) { + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, _ipfsd.api) + }) + } + }) }, - teardown: function (cb) { - factory.dismantle(cb) + teardown: function (callback) { + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/core/interface/object.js b/test/core/interface/object.js index 97ac3e3b64..32ef8e0251 100644 --- a/test/core/interface/object.js +++ b/test/core/interface/object.js @@ -1,19 +1,32 @@ /* eslint-env mocha */ - 'use strict' const test = require('interface-ipfs-core') -const IPFSFactory = require('../../utils/ipfs-factory-instance') +const parallel = require('async/parallel') + +const IPFS = require('../../../src') -let factory +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ type: 'proc', exec: IPFS }) +const nodes = [] const common = { - setup: function (cb) { - factory = new IPFSFactory() - cb(null, factory) + setup: function (callback) { + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, _ipfsd.api) + }) + } + }) }, - teardown: function (cb) { - factory.dismantle(cb) + teardown: function (callback) { + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/core/interface/pubsub.js b/test/core/interface/pubsub.js index 4264b0c96b..2425f862d9 100644 --- a/test/core/interface/pubsub.js +++ b/test/core/interface/pubsub.js @@ -2,17 +2,32 @@ 'use strict' const test = require('interface-ipfs-core') -const IPFSFactory = require('../../utils/ipfs-factory-instance') +const parallel = require('async/parallel') -let factory +const IPFS = require('../../../src') +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ type: 'proc', exec: IPFS }) + +const nodes = [] const common = { - setup: function (cb) { - factory = new IPFSFactory() - cb(null, factory) + setup: function (callback) { + callback(null, { + spawnNode: (cb) => { + df.spawn({ args: ['--enable-pubsub-experiment'] }, + (err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, _ipfsd.api) + }) + } + }) }, - teardown: function (cb) { - factory.dismantle(cb) + teardown: function (callback) { + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/core/interface/swarm.js b/test/core/interface/swarm.js index 15da9f484a..d5158701d8 100644 --- a/test/core/interface/swarm.js +++ b/test/core/interface/swarm.js @@ -1,19 +1,42 @@ /* eslint-env mocha */ - 'use strict' const test = require('interface-ipfs-core') -const IPFSFactory = require('../../utils/ipfs-factory-instance') +const parallel = require('async/parallel') + +const IPFS = require('../../../src') -let factory +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ type: 'proc', exec: IPFS }) +const nodes = [] const common = { - setup: function (cb) { - factory = new IPFSFactory() - cb(null, factory) + setup: function (callback) { + callback(null, { + spawnNode: (repoPath, config, cb) => { + if (typeof repoPath === 'function') { + cb = repoPath + repoPath = undefined + } + + if (typeof config === 'function') { + cb = config + config = undefined + } + + df.spawn({ repoPath, config }, (err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, _ipfsd.api) + }) + } + }) }, - teardown: function (cb) { - factory.dismantle(cb) + teardown: function (callback) { + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/core/kad-dht.node.js b/test/core/kad-dht.node.js index 1bd0123575..db91cdc168 100644 --- a/test/core/kad-dht.node.js +++ b/test/core/kad-dht.node.js @@ -7,10 +7,29 @@ const dirtyChai = require('dirty-chai') const expect = chai.expect chai.use(dirtyChai) const parallel = require('async/parallel') -const IPFSFactory = require('../utils/ipfs-factory-instance') + +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ type: 'js' }) + +const config = { + Addresses: { + Swarm: [`/ip4/127.0.0.1/tcp/0`, `/ip4/127.0.0.1/tcp/0/ws`], + API: `/ip4/127.0.0.1/tcp/0`, + Gateway: `/ip4/127.0.0.1/tcp/0` + }, + Bootstrap: [], + Discovery: { + MDNS: { + Enabled: false + } + } +} + +function createNode (callback) { + df.spawn({ exec: './src/cli/bin.js', config }, callback) +} describe('verify that kad-dht is doing its thing', () => { - let factory let nodeA let nodeB let nodeC @@ -18,18 +37,18 @@ describe('verify that kad-dht is doing its thing', () => { let addrB let addrC + let nodes before((done) => { - factory = new IPFSFactory() - parallel([ - (cb) => factory.spawnNode(cb), - (cb) => factory.spawnNode(cb), - (cb) => factory.spawnNode(cb) - ], (err, nodes) => { + (cb) => createNode(cb), + (cb) => createNode(cb), + (cb) => createNode(cb) + ], (err, _nodes) => { expect(err).to.not.exist() - nodeA = nodes[0] - nodeB = nodes[1] - nodeC = nodes[2] + nodes = _nodes + nodeA = _nodes[0].api + nodeB = _nodes[1].api + nodeC = _nodes[2].api parallel([ (cb) => nodeA.id(cb), (cb) => nodeB.id(cb), @@ -47,7 +66,7 @@ describe('verify that kad-dht is doing its thing', () => { }) }) - after((done) => factory.dismantle(done)) + after((done) => parallel(nodes.map((node) => (cb) => node.stop(cb)), done)) it.skip('add a file in C, fetch through B in A', function (done) { this.timeout(10 * 1000) diff --git a/test/http-api/interface/block.js b/test/http-api/interface/block.js index db39d378c6..9b5af8aa1a 100644 --- a/test/http-api/interface/block.js +++ b/test/http-api/interface/block.js @@ -1,19 +1,30 @@ /* eslint-env mocha */ - 'use strict' const test = require('interface-ipfs-core') -const FactoryClient = require('./../../utils/ipfs-factory-daemon') +const parallel = require('async/parallel') -let fc +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) +const nodes = [] const common = { setup: function (callback) { - fc = new FactoryClient() - callback(null, fc) + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, _ipfsd.api) + }) + } + }) }, teardown: function (callback) { - fc.dismantle(callback) + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/http-api/interface/config.js b/test/http-api/interface/config.js index 30837f8b86..2dc5e28c9f 100644 --- a/test/http-api/interface/config.js +++ b/test/http-api/interface/config.js @@ -1,19 +1,30 @@ /* eslint-env mocha */ - 'use strict' const test = require('interface-ipfs-core') -const FactoryClient = require('./../../utils/ipfs-factory-daemon') +const parallel = require('async/parallel') -let fc +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) +const nodes = [] const common = { setup: function (callback) { - fc = new FactoryClient() - callback(null, fc) + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, _ipfsd.api) + }) + } + }) }, teardown: function (callback) { - fc.dismantle(callback) + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/http-api/interface/files.js b/test/http-api/interface/files.js index 84b150f79f..8b67070415 100644 --- a/test/http-api/interface/files.js +++ b/test/http-api/interface/files.js @@ -1,19 +1,30 @@ /* eslint-env mocha */ - 'use strict' const test = require('interface-ipfs-core') -const FactoryClient = require('./../../utils/ipfs-factory-daemon') +const parallel = require('async/parallel') -let fc +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) +const nodes = [] const common = { setup: function (callback) { - fc = new FactoryClient() - callback(null, fc) + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, _ipfsd.api) + }) + } + }) }, teardown: function (callback) { - fc.dismantle(callback) + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/http-api/interface/object.js b/test/http-api/interface/object.js index e00df72564..5db1e53f97 100644 --- a/test/http-api/interface/object.js +++ b/test/http-api/interface/object.js @@ -1,19 +1,30 @@ /* eslint-env mocha */ - 'use strict' const test = require('interface-ipfs-core') -const FactoryClient = require('./../../utils/ipfs-factory-daemon') +const parallel = require('async/parallel') -let fc +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) +const nodes = [] const common = { setup: function (callback) { - fc = new FactoryClient() - callback(null, fc) + callback(null, { + spawnNode: (cb) => { + df.spawn((err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, _ipfsd.api) + }) + } + }) }, teardown: function (callback) { - fc.dismantle(callback) + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/http-api/interface/pubsub.js b/test/http-api/interface/pubsub.js index ab474fac9f..b058c1a63c 100644 --- a/test/http-api/interface/pubsub.js +++ b/test/http-api/interface/pubsub.js @@ -1,19 +1,31 @@ /* eslint-env mocha */ - 'use strict' const test = require('interface-ipfs-core') -const FactoryClient = require('./../../utils/ipfs-factory-daemon') +const parallel = require('async/parallel') -let fc +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) +const nodes = [] const common = { setup: function (callback) { - fc = new FactoryClient() - callback(null, fc) + callback(null, { + spawnNode: (cb) => { + df.spawn({ args: ['--enable-pubsub-experiment'] }, + (err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, _ipfsd.api) + }) + } + }) }, teardown: function (callback) { - fc.dismantle(callback) + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/http-api/interface/swarm.js b/test/http-api/interface/swarm.js index eeca079124..e2a9b657c7 100644 --- a/test/http-api/interface/swarm.js +++ b/test/http-api/interface/swarm.js @@ -1,19 +1,40 @@ /* eslint-env mocha */ - 'use strict' const test = require('interface-ipfs-core') -const FactoryClient = require('./../../utils/ipfs-factory-daemon') +const parallel = require('async/parallel') -let fc +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create({ exec: 'src/cli/bin.js' }) +const nodes = [] const common = { setup: function (callback) { - fc = new FactoryClient() - callback(null, fc) + callback(null, { + spawnNode: (repoPath, config, cb) => { + if (typeof repoPath === 'function') { + cb = repoPath + repoPath = undefined + } + + if (typeof config === 'function') { + cb = config + config = undefined + } + + df.spawn({ repoPath, config }, (err, _ipfsd) => { + if (err) { + return cb(err) + } + + nodes.push(_ipfsd) + cb(null, _ipfsd.api) + }) + } + }) }, teardown: function (callback) { - fc.dismantle(callback) + parallel(nodes.map((node) => (cb) => node.stop(cb)), callback) } } diff --git a/test/utils/another-daemon-spawner.js b/test/utils/another-daemon-spawner.js deleted file mode 100644 index 5d55be3295..0000000000 --- a/test/utils/another-daemon-spawner.js +++ /dev/null @@ -1,73 +0,0 @@ -/* eslint-env mocha */ - -'use strict' - -const waterfall = require('async/waterfall') -const series = require('async/series') - -const relayConfig = require('./ipfs-factory-daemon/default-config.json') -const Factory = require('./ipfs-factory-daemon') - -const nodes = [] -const factory = new Factory() -exports = module.exports - -exports.spawnJsNode = (addrs, hop, api, gateway, callback) => { - let relayPeer - let relayAddrs - - if (typeof hop === 'function') { - callback = hop - hop = false - } - if (typeof api === 'function') { - callback = api - api = 0 - } - if (typeof gateway === 'function') { - callback = gateway - gateway = 0 - } - - api = api || 0 - gateway = gateway || 0 - - callback = callback || function noop () {} - - waterfall([ - (cb) => factory.spawnNode(null, Object.assign(relayConfig, { - Addresses: { - Swarm: addrs, - API: `/ip4/0.0.0.0/tcp/${api}`, - Gateway: `/ip4/0.0.0.0/tcp/${gateway}` - }, - EXPERIMENTAL: { - Swarm: { - DisableRelay: false, - EnableRelayHop: hop - } - } - }), cb), - (node, cb) => { - relayPeer = node - relayPeer.swarm.localAddrs(cb) - }, - (addrs, cb) => { - relayAddrs = addrs - cb() - } - ], (err) => { - if (err) { - return callback(err) - } - callback(null, relayPeer, relayAddrs) - }) -} - -exports.stopNodes = (callback) => { - series([ - (cb) => factory.dismantle(cb) - ].concat(nodes.map((node) => (cb) => { - setTimeout(() => node.stop(cb), 100) - })), callback) -} diff --git a/test/utils/ipfs-factory-daemon/default-config.json b/test/utils/ipfs-factory-daemon/default-config.json deleted file mode 100644 index f2203594df..0000000000 --- a/test/utils/ipfs-factory-daemon/default-config.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "Identity": { - "PeerID": "", - "PrivKey": "" - }, - "Addresses": { - "Swarm": [ - "/ip4/127.0.0.1/tcp/0" - ], - "API": "/ip4/127.0.0.1/tcp/0", - "Gateway": "/ip4/127.0.0.1/tcp/0" - }, - "Version": { - "Current": "jsipfs-dev", - "Check": "error", - "CheckDate": "0001-01-01T00:00:00Z", - "CheckPeriod": "172800000000000", - "AutoUpdate": "minor" - }, - "Discovery": { - "MDNS": { - "Enabled": false, - "Interval": 10 - }, - "webRTCStar": { - "Enabled": false - } - }, - "Bootstrap": [], - "Gateway": { - "HTTPHeaders": null, - "RootRedirect": "", - "Writable": false - }, - "API": { - "HTTPHeaders": null - }, - "Swarm": { - "AddrFilters": null - } -} diff --git a/test/utils/ipfs-factory-daemon/index.js b/test/utils/ipfs-factory-daemon/index.js deleted file mode 100644 index 2dde6d4eef..0000000000 --- a/test/utils/ipfs-factory-daemon/index.js +++ /dev/null @@ -1,79 +0,0 @@ -'use strict' - -const PeerId = require('peer-id') -const IPFSAPI = require('ipfs-api') -const clean = require('../clean') -const HttpApi = require('../../../src/http') -const series = require('async/series') -const eachSeries = require('async/eachSeries') -const defaultConfig = require('./default-config.json') -const os = require('os') -const hat = require('hat') - -class Factory { - constructor () { - this.daemonsSpawned = [] - } - - /* yields a new started node */ - spawnNode (repoPath, suppliedConfig, callback) { - if (typeof repoPath === 'function') { - callback = repoPath - repoPath = undefined - } - if (typeof suppliedConfig === 'function') { - callback = suppliedConfig - suppliedConfig = {} - } - - repoPath = repoPath || os.tmpdir() + '/ipfs-' + hat() - - let daemon - let ctl - let config - - series([ - (cb) => { - // prepare config for node - - config = Object.assign({}, defaultConfig, suppliedConfig) - - PeerId.create({ bits: 1024 }, (err, id) => { - if (err) { return cb(err) } - - const peerId = id.toJSON() - config.Identity.PeerID = peerId.id - config.Identity.PrivKey = peerId.privKey - cb() - }) - }, - (cb) => { - daemon = new HttpApi(repoPath, config, {enablePubsubExperiment: true}) - daemon.repoPath = repoPath - this.daemonsSpawned.push(daemon) - - daemon.start(true, cb) - }, - (cb) => { - ctl = IPFSAPI(daemon.apiMultiaddr) - ctl.repoPath = repoPath - ctl.apiMultiaddr = daemon.apiMultiaddr - cb() - } - ], (err) => callback(err, ctl)) - } - - dismantle (callback) { - eachSeries(this.daemonsSpawned, (d, cb) => { - d.stop((err) => { - clean(d.repoPath) - if (err) { - console.error('error stopping', err) - } - cb(err) - }) - }, callback) - } -} - -module.exports = Factory diff --git a/test/utils/ipfs-factory-instance/default-config.json b/test/utils/ipfs-factory-instance/default-config.json deleted file mode 100644 index 677c7c85d9..0000000000 --- a/test/utils/ipfs-factory-instance/default-config.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "Addresses": { - "Swarm": [ - "/ip4/127.0.0.1/tcp/0" - ], - "API": "/ip4/127.0.0.1/tcp/0", - "Gateway": "/ip4/127.0.0.1/tcp/0" - }, - "Version": { - "Current": "jsipfs-dev", - "Check": "error", - "CheckDate": "0001-01-01T00:00:00Z", - "CheckPeriod": "172800000000000", - "AutoUpdate": "minor" - }, - "Discovery": { - "MDNS": { - "Enabled": false, - "Interval": 10 - }, - "webRTCStar": { - "Enabled": false - } - }, - "Bootstrap": [], - "API": { - "HTTPHeaders": null - } -} diff --git a/test/utils/ipfs-factory-instance/index.js b/test/utils/ipfs-factory-instance/index.js deleted file mode 100644 index 568a1710a7..0000000000 --- a/test/utils/ipfs-factory-instance/index.js +++ /dev/null @@ -1,63 +0,0 @@ -'use strict' - -const series = require('async/series') -const each = require('async/each') -const hat = require('hat') -const os = require('os') -const path = require('path') - -const defaultConfig = require('./default-config.json') -const IPFS = require('../../../src/core') -const createTempRepo = require('../create-repo-nodejs') - -module.exports = Factory - -function Factory () { - if (!(this instanceof Factory)) { - return new Factory() - } - - const nodes = [] - - /* yields a new started node instance */ - this.spawnNode = (repoPath, suppliedConfig, callback) => { - if (typeof repoPath === 'function') { - callback = repoPath - repoPath = undefined - } - - if (typeof suppliedConfig === 'function') { - callback = suppliedConfig - suppliedConfig = {} - } - - if (!repoPath) { - repoPath = path.join(os.tmpdir(), '.ipfs-' + hat()) - } - - const config = Object.assign({}, defaultConfig, suppliedConfig) - - const repo = createTempRepo(repoPath) - const node = new IPFS({ - repo: repo, - init: { bits: 1024 }, - config: config, - EXPERIMENTAL: { - pubsub: true, - dht: true - } - }) - - node.once('ready', () => { - nodes.push({ repo: repo, ipfs: node }) - callback(null, node) - }) - } - - this.dismantle = function (callback) { - series([ - (cb) => each(nodes, (el, cb) => el.ipfs.stop(cb), cb), - (cb) => each(nodes, (el, cb) => el.repo.teardown(cb), cb) - ], callback) - } -} diff --git a/test/utils/on-and-off.js b/test/utils/on-and-off.js index 8a79c660ef..4aa6344eeb 100644 --- a/test/utils/on-and-off.js +++ b/test/utils/on-and-off.js @@ -1,7 +1,6 @@ /* eslint-env mocha */ 'use strict' -const Factory = require('../utils/ipfs-factory-daemon') const hat = require('hat') const chai = require('chai') const dirtyChai = require('dirty-chai') @@ -12,6 +11,9 @@ const ipfsExec = require('../utils/ipfs-exec') const clean = require('../utils/clean') const os = require('os') +const DaemonFactory = require('ipfsd-ctl') +const df = DaemonFactory.create() + function off (tests) { describe('daemon off (directly to core)', () => { let thing = {} @@ -27,7 +29,7 @@ function off (tests) { }) after(function (done) { - this.timeout(26 * 1000) + this.timeout(20 * 1000) clean(repoPath) setImmediate(done) }) @@ -38,19 +40,18 @@ function off (tests) { function on (tests) { describe('daemon on (through http-api)', () => { - let factory let thing = {} + let ipfsd before(function (done) { // CI takes longer to instantiate the daemon, // so we need to increase the timeout for the // before step this.timeout(60 * 1000) - factory = new Factory() - - factory.spawnNode((err, node) => { + df.spawn({ type: 'js', exec: `./src/cli/bin.js` }, (err, node) => { expect(err).to.not.exist() + ipfsd = node thing.ipfs = ipfsExec(node.repoPath) thing.ipfs.repoPath = node.repoPath done() @@ -58,8 +59,8 @@ function on (tests) { }) after(function (done) { - this.timeout(60 * 1000) - factory.dismantle(done) + this.timeout(15 * 1000) + ipfsd.stop(done) }) tests(thing)