diff --git a/package.json b/package.json index 423109411..955cb94af 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "cross-env": "^6.0.0", "detect-node": "^2.0.4", "go-ipfs-dep": "^0.4.22", - "interface-ipfs-core": "^0.121.0", + "interface-ipfs-core": "^0.122.0", "ipfsd-ctl": "^0.47.1", "ndjson": "^1.5.0", "nock": "^11.4.0", diff --git a/test/interface.spec.js b/test/interface.spec.js index 760962b38..dc41ec325 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -7,7 +7,7 @@ const CommonFactory = require('./utils/interface-common-factory') const isWindows = process.platform && process.platform === 'win32' describe('interface-ipfs-core tests', () => { - const defaultCommonFactory = CommonFactory.create() + const defaultCommonFactory = CommonFactory.createAsync() tests.bitswap(defaultCommonFactory, { skip: [ @@ -172,7 +172,7 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.name(CommonFactory.create({ + tests.name(CommonFactory.createAsync({ spawnOptions: { args: ['--offline'] } @@ -186,8 +186,7 @@ describe('interface-ipfs-core tests', () => { ] }) - // TODO: uncomment after https://github.com/ipfs/interface-ipfs-core/pull/361 being merged and a new release - tests.namePubsub(CommonFactory.create({ + tests.namePubsub(CommonFactory.createAsync({ spawnOptions: { args: ['--enable-namesys-pubsub'], initOptions: { bits: 1024, profile: 'test' } @@ -228,7 +227,7 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.pubsub(CommonFactory.create({ + tests.pubsub(CommonFactory.createAsync({ spawnOptions: { args: ['--enable-pubsub-experiment'], initOptions: { bits: 1024, profile: 'test' } @@ -251,5 +250,5 @@ describe('interface-ipfs-core tests', () => { tests.stats(defaultCommonFactory) - tests.swarm(CommonFactory.createAsync()) + tests.swarm(defaultCommonFactory) }) diff --git a/test/utils/interface-common-factory.js b/test/utils/interface-common-factory.js index 4a47fda42..bd4720b6e 100644 --- a/test/utils/interface-common-factory.js +++ b/test/utils/interface-common-factory.js @@ -6,10 +6,14 @@ const IPFSFactory = require('ipfsd-ctl') const ipfsClient = require('../../src') const merge = require('merge-options') +const DEFAULT_FACTORY_OPTIONS = { + IpfsClient: ipfsClient +} + function createFactory (options) { options = options || {} - options.factoryOptions = options.factoryOptions || { IpfsClient: ipfsClient } + options.factoryOptions = options.factoryOptions || { ...DEFAULT_FACTORY_OPTIONS } options.spawnOptions = options.spawnOptions || { initOptions: { bits: 1024, profile: 'test' } } const ipfsFactory = IPFSFactory.create(options.factoryOptions) @@ -52,19 +56,18 @@ function createFactory (options) { } } -function createAsync (createFactoryOptions, createSpawnOptions) { +function createAsync (options = {}) { return () => { const nodes = [] - const setup = async (factoryOptions = {}, spawnOptions) => { + const setup = async (setupOptions = {}) => { const ipfsFactory = IPFSFactory.create(merge( - { IpfsClient: ipfsClient }, - factoryOptions, - createFactoryOptions + options.factoryOptions ? {} : { ...DEFAULT_FACTORY_OPTIONS }, + setupOptions.factoryOptions, + options.factoryOptions )) const node = await ipfsFactory.spawn(merge( - { initOptions: { profile: 'test' } }, - spawnOptions, - createSpawnOptions + setupOptions.spawnOptions, + options.spawnOptions || { initOptions: { profile: 'test' } } )) nodes.push(node)