diff --git a/.aegir.js b/.aegir.js index 424edce795..eeaa752bc2 100644 --- a/.aegir.js +++ b/.aegir.js @@ -1,10 +1,8 @@ 'use strict' const IPFSFactory = require('ipfsd-ctl') -const parallel = require('async/parallel') const MockPreloadNode = require('./test/utils/mock-preload-node') const EchoServer = require('interface-ipfs-core/src/utils/echo-http-server') -const callbackify = require('callbackify') const ipfsdServer = IPFSFactory.createServer() const preloadNode = MockPreloadNode.createNode() @@ -29,40 +27,26 @@ module.exports = { }, hooks: { node: { - pre: (cb) => { - parallel([ - (cb) => callbackify(preloadNode.start)(cb), - (cb) => echoServer.start(cb) - ], cb) - }, - post: (cb) => { - parallel([ - (cb) => callbackify(preloadNode.stop)(cb), - (cb) => echoServer.stop(cb) - ], cb) - } + pre: () => Promise.all([ + preloadNode.start(), + echoServer.start() + ]), + post: () => Promise.all([ + preloadNode.stop(), + echoServer.stop() + ]) }, browser: { - pre: (cb) => { - parallel([ - (cb) => { - ipfsdServer.start() - cb() - }, - (cb) => callbackify(preloadNode.start)(cb), - (cb) => echoServer.start(cb) - ], cb) - }, - post: (cb) => { - parallel([ - (cb) => { - ipfsdServer.stop() - cb() - }, - (cb) => callbackify(preloadNode.stop)(cb), - (cb) => echoServer.stop(cb) - ], cb) - } + pre: () => Promise.all([ + ipfsdServer.start(), + preloadNode.start(), + echoServer.start() + ]), + post: () => Promise.all([ + ipfsdServer.stop(), + preloadNode.stop(), + echoServer.stop() + ]) } } } diff --git a/package.json b/package.json index 1837f58e65..c61be3f6df 100644 --- a/package.json +++ b/package.json @@ -162,7 +162,7 @@ "p-iteration": "^1.1.8", "p-queue": "^6.1.0", "peer-book": "^0.9.1", - "peer-id": "^0.12.2", + "peer-id": "~0.12.2", "peer-info": "~0.15.1", "pretty-bytes": "^5.3.0", "progress": "^2.0.1", @@ -205,7 +205,7 @@ "execa": "^3.0.0", "form-data": "^3.0.0", "hat": "0.0.3", - "interface-ipfs-core": "^0.121.0", + "interface-ipfs-core": "^0.124.1", "ipfs-interop": "^0.1.1", "ipfsd-ctl": "^0.47.2", "libp2p-websocket-star": "~0.10.2", diff --git a/src/core/components/bootstrap.js b/src/core/components/bootstrap.js index 156ecc1134..dad39cdd26 100644 --- a/src/core/components/bootstrap.js +++ b/src/core/components/bootstrap.js @@ -45,8 +45,10 @@ module.exports = function bootstrap (self) { throw invalidMultiaddrError(multiaddr) } + let res = [] const config = await self._repo.config.get() if (args.all) { + res = config.Bootstrap config.Bootstrap = [] } else { config.Bootstrap = config.Bootstrap.filter((mh) => mh !== multiaddr) @@ -54,7 +56,6 @@ module.exports = function bootstrap (self) { await self._repo.config.set(config) - const res = [] if (!args.all && multiaddr) { res.push(multiaddr) } diff --git a/test/cli/bootstrap.js b/test/cli/bootstrap.js index 3d5f0f6562..b9e4f1659b 100644 --- a/test/cli/bootstrap.js +++ b/test/cli/bootstrap.js @@ -94,10 +94,12 @@ describe('bootstrap', () => runOnAndOff((thing) => { it('rm all bootstrap nodes', async function () { this.timeout(40 * 1000) - const out = await ipfs('bootstrap rm --all') - expect(out).to.equal('') + const outListBefore = await ipfs('bootstrap list') - const out2 = await ipfs('bootstrap list') - expect(out2).to.equal('') + const outRm = await ipfs('bootstrap rm --all') + expect(outRm).to.equal(outListBefore) + + const outListAfter = await ipfs('bootstrap list') + expect(outListAfter).to.equal('') }) })) diff --git a/test/core/interface.spec.js b/test/core/interface.spec.js index 0ffe937ab1..bfc0cb6508 100644 --- a/test/core/interface.spec.js +++ b/test/core/interface.spec.js @@ -8,7 +8,7 @@ const isNode = require('detect-node') describe('interface-ipfs-core tests', function () { this.timeout(20 * 1000) - const defaultCommonFactory = CommonFactory.create() + const defaultCommonFactory = CommonFactory.createAsync() tests.bitswap(defaultCommonFactory, { skip: !isNode }) @@ -20,7 +20,7 @@ describe('interface-ipfs-core tests', function () { tests.dag(defaultCommonFactory) - tests.dht(CommonFactory.create({ + tests.dht(CommonFactory.createAsync({ spawnOptions: { config: { Bootstrap: [], @@ -53,7 +53,7 @@ describe('interface-ipfs-core tests', function () { tests.filesMFS(defaultCommonFactory) - tests.key(CommonFactory.create({ + tests.key(CommonFactory.createAsync({ spawnOptions: { args: ['--pass ipfs-is-awesome-software'], initOptions: { bits: 512 }, @@ -71,21 +71,19 @@ describe('interface-ipfs-core tests', function () { } })) - tests.miscellaneous(CommonFactory.create({ - // No need to stop, because the test suite does a 'stop' test. - createTeardown: () => cb => cb(), + tests.miscellaneous(CommonFactory.createAsync({ spawnOptions: { args: ['--pass ipfs-is-awesome-software', '--offline'] } })) - tests.name(CommonFactory.create({ + tests.name(CommonFactory.createAsync({ spawnOptions: { args: ['--pass ipfs-is-awesome-software', '--offline'] } })) - tests.namePubsub(CommonFactory.create({ + tests.namePubsub(CommonFactory.createAsync({ spawnOptions: { args: ['--enable-namesys-pubsub'], initOptions: { bits: 1024 }, @@ -120,7 +118,7 @@ describe('interface-ipfs-core tests', function () { } }) - tests.pubsub(CommonFactory.create({ + tests.pubsub(CommonFactory.createAsync({ spawnOptions: { initOptions: { bits: 512 } } @@ -134,5 +132,5 @@ describe('interface-ipfs-core tests', function () { tests.stats(defaultCommonFactory) - tests.swarm(CommonFactory.createAsync(), { skip: !isNode }) + tests.swarm(defaultCommonFactory, { skip: !isNode }) }) diff --git a/test/http-api/inject/bootstrap.js b/test/http-api/inject/bootstrap.js index 8e59ab89d0..69dc4b3d88 100644 --- a/test/http-api/inject/bootstrap.js +++ b/test/http-api/inject/bootstrap.js @@ -83,7 +83,7 @@ module.exports = (http) => { }) expect(res.statusCode).to.be.eql(200) - expect(res.result.Peers).to.be.eql([]) + expect(res.result.Peers).to.be.eql(defaultList) }) }) } diff --git a/test/http-api/interface.js b/test/http-api/interface.js index c73a5d0c6e..93880d2791 100644 --- a/test/http-api/interface.js +++ b/test/http-api/interface.js @@ -6,7 +6,7 @@ const CommonFactory = require('../utils/interface-common-factory') const path = require('path') describe('interface-ipfs-core over ipfs-http-client tests', () => { - const defaultCommonFactory = CommonFactory.create({ + const defaultCommonFactory = CommonFactory.createAsync({ factoryOptions: { exec: path.resolve(`${__dirname}/../../src/cli/bin.js`) } }) @@ -28,7 +28,7 @@ describe('interface-ipfs-core over ipfs-http-client tests', () => { }] }) - tests.dht(CommonFactory.create({ + tests.dht(CommonFactory.createAsync({ spawnOptions: { initOptions: { bits: 512 }, config: { @@ -54,7 +54,7 @@ describe('interface-ipfs-core over ipfs-http-client tests', () => { tests.filesMFS(defaultCommonFactory) - tests.key(CommonFactory.create({ + tests.key(CommonFactory.createAsync({ spawnOptions: { args: ['--pass ipfs-is-awesome-software'], initOptions: { bits: 512 }, @@ -73,21 +73,19 @@ describe('interface-ipfs-core over ipfs-http-client tests', () => { } })) - tests.miscellaneous(CommonFactory.create({ - // No need to stop, because the test suite does a 'stop' test. - createTeardown: () => cb => cb(), + tests.miscellaneous(CommonFactory.createAsync({ spawnOptions: { args: ['--pass ipfs-is-awesome-software', '--offline'] } })) - tests.name(CommonFactory.create({ + tests.name(CommonFactory.createAsync({ spawnOptions: { args: ['--pass ipfs-is-awesome-software', '--offline'] } })) - tests.namePubsub(CommonFactory.create({ + tests.namePubsub(CommonFactory.createAsync({ spawnOptions: { args: ['--enable-namesys-pubsub'], initOptions: { bits: 1024 }, @@ -118,7 +116,7 @@ describe('interface-ipfs-core over ipfs-http-client tests', () => { tests.ping(defaultCommonFactory) - tests.pubsub(CommonFactory.create({ + tests.pubsub(CommonFactory.createAsync({ spawnOptions: { initOptions: { bits: 512 } } diff --git a/test/utils/interface-common-factory.js b/test/utils/interface-common-factory.js index b0a245fb0b..ebca12f962 100644 --- a/test/utils/interface-common-factory.js +++ b/test/utils/interface-common-factory.js @@ -8,10 +8,15 @@ const callbackify = require('callbackify') const mergeOptions = require('merge-options') const IPFS = require('../../src') +const DEFAULT_FACTORY_OPTIONS = { + type: 'proc', + exec: IPFS +} + function createFactory (options) { options = options || {} - options.factoryOptions = options.factoryOptions || { type: 'proc', exec: IPFS } + options.factoryOptions = options.factoryOptions || { ...DEFAULT_FACTORY_OPTIONS } options.spawnOptions = mergeOptions({ initOptions: { bits: 512 }, config: { @@ -68,25 +73,24 @@ function createFactory (options) { } } -function createAsync (createFactoryOptions = {}, createSpawnOptions = {}) { +function createAsync (options = {}) { return () => { const nodes = [] - const setup = async (factoryOptions = {}, spawnOptions = {}) => { - factoryOptions = mergeOptions( - { - type: 'proc', - exec: IPFS - }, - factoryOptions, - createFactoryOptions + const setup = async (setupOptions = {}) => { + options.factoryOptions = mergeOptions( + options.factoryOptions ? {} : { ...DEFAULT_FACTORY_OPTIONS }, + setupOptions.factoryOptions, + options.factoryOptions ) + // When not an in proc daemon use the http-client js-ipfs depends on, not the one from ipfsd-ctl - if (factoryOptions.type !== 'proc') { - factoryOptions.IpfsClient = factoryOptions.IpfsClient || ipfsClient + if (options.factoryOptions.type !== 'proc') { + options.factoryOptions.IpfsClient = options.factoryOptions.IpfsClient || ipfsClient } - const ipfsFactory = IPFSFactory.create(factoryOptions) - const node = await ipfsFactory.spawn(mergeOptions( + const ipfsFactory = IPFSFactory.create(options.factoryOptions) + + options.spawnOptions = mergeOptions( { config: { Bootstrap: [], @@ -101,9 +105,12 @@ function createAsync (createFactoryOptions = {}, createSpawnOptions = {}) { }, preload: { enabled: false } }, - spawnOptions, - createSpawnOptions - )) + setupOptions.spawnOptions, + options.spawnOptions + ) + + const node = await ipfsFactory.spawn(options.spawnOptions) + nodes.push(node) const id = await node.api.id()