From 224a4cccbb634c57d4b2b675c9401a5afd8c81f2 Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Fri, 11 Oct 2019 15:50:05 +0100 Subject: [PATCH 1/7] fix: use new ipfsd-ctl setup --- test/interface.spec.js | 124 +++++++++++-------------- test/utils/interface-common-factory.js | 92 ------------------ 2 files changed, 55 insertions(+), 161 deletions(-) delete mode 100644 test/utils/interface-common-factory.js diff --git a/test/interface.spec.js b/test/interface.spec.js index dc41ec325..7adb542e5 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -2,47 +2,29 @@ 'use strict' const tests = require('interface-ipfs-core') -const isNode = require('detect-node') -const CommonFactory = require('./utils/interface-common-factory') +const merge = require('merge-options') +const { isNode } = require('ipfs-utils/src/env') +const ctl = require('ipfsd-ctl') const isWindows = process.platform && process.platform === 'win32' describe('interface-ipfs-core tests', () => { - const defaultCommonFactory = CommonFactory.createAsync() + const commonOptions = { + factoryOptions: { IpfsClient: require('../src') } + } + const commonFactory = ctl.createTestsInterface(commonOptions) - tests.bitswap(defaultCommonFactory, { - skip: [ - // bitswap.stat - { - name: 'should not get bitswap stats when offline', - reason: 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078' - }, - // bitswap.wantlist - { - name: 'should not get the wantlist when offline', - reason: 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078' - }, - // bitswap.unwant - { - name: 'should remove a key from the wantlist', - reason: 'FIXME why is this skipped?' - }, - { - name: 'should not remove a key from the wantlist when offline', - reason: 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078' - } - ] - }) + tests.bitswap(commonFactory) - tests.block(defaultCommonFactory, { + tests.block(commonFactory, { skip: [{ name: 'should get a block added as CIDv1 with a CIDv0', reason: 'go-ipfs does not support the `version` param' }] }) - tests.bootstrap(defaultCommonFactory) + tests.bootstrap(commonFactory) - tests.config(defaultCommonFactory, { + tests.config(commonFactory, { skip: [ // config.replace { @@ -60,7 +42,7 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.dag(defaultCommonFactory, { + tests.dag(commonFactory, { skip: [ // dag.tree { @@ -87,7 +69,7 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.dht(defaultCommonFactory, { + tests.dht(commonFactory, { skip: [ // dht.findpeer { @@ -107,47 +89,47 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.filesRegular(defaultCommonFactory, { + tests.filesMFS(commonFactory, { skip: [ - // .addFromFs - isNode ? null : { - name: 'addFromFs', - reason: 'Not designed to run in the browser' - }, - // .catPullStream { - name: 'should export a chunk of a file', - reason: 'TODO not implemented in go-ipfs yet' + name: 'should ls directory with long option', + reason: 'TODO unskip when go-ipfs supports --long https://github.com/ipfs/go-ipfs/pull/6528' }, { - name: 'should export a chunk of a file in a Pull Stream', + name: 'should read from outside of mfs', reason: 'TODO not implemented in go-ipfs yet' }, { - name: 'should export a chunk of a file in a Readable Stream', + name: 'should ls from outside of mfs', reason: 'TODO not implemented in go-ipfs yet' } ] }) - tests.filesMFS(defaultCommonFactory, { + tests.filesRegular(commonFactory, { skip: [ + // .addFromFs + isNode ? null : { + name: 'addFromFs', + reason: 'Not designed to run in the browser' + }, + // .catPullStream { - name: 'should ls directory with long option', - reason: 'TODO unskip when go-ipfs supports --long https://github.com/ipfs/go-ipfs/pull/6528' + name: 'should export a chunk of a file', + reason: 'TODO not implemented in go-ipfs yet' }, { - name: 'should read from outside of mfs', + name: 'should export a chunk of a file in a Pull Stream', reason: 'TODO not implemented in go-ipfs yet' }, { - name: 'should ls from outside of mfs', + name: 'should export a chunk of a file in a Readable Stream', reason: 'TODO not implemented in go-ipfs yet' } ] }) - tests.key(defaultCommonFactory, { + tests.key(commonFactory, { skip: [ // key.export { @@ -162,7 +144,7 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.miscellaneous(defaultCommonFactory, { + tests.miscellaneous(commonFactory, { skip: [ // stop { @@ -172,11 +154,13 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.name(CommonFactory.createAsync({ - spawnOptions: { - args: ['--offline'] + tests.name(ctl.createTestsInterface(merge(commonOptions, + { + spawnOptions: { + args: ['--offline'] + } } - }), { + )), { skip: [ // stop { @@ -186,12 +170,13 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.namePubsub(CommonFactory.createAsync({ - spawnOptions: { - args: ['--enable-namesys-pubsub'], - initOptions: { bits: 1024, profile: 'test' } + tests.namePubsub(ctl.createTestsInterface(merge(commonOptions, + { + spawnOptions: { + args: ['--enable-namesys-pubsub'] + } } - }), { + )), { skip: [ // name.pubsub.cancel { @@ -206,11 +191,11 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.object(defaultCommonFactory) + tests.object(commonFactory) - tests.pin(defaultCommonFactory) + tests.pin(commonFactory) - tests.ping(defaultCommonFactory, { + tests.ping(commonFactory, { skip: [ { name: 'should fail when pinging an unknown peer over pull stream', @@ -227,12 +212,13 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.pubsub(CommonFactory.createAsync({ - spawnOptions: { - args: ['--enable-pubsub-experiment'], - initOptions: { bits: 1024, profile: 'test' } + tests.pubsub(ctl.createTestsInterface(merge(commonOptions, + { + spawnOptions: { + args: ['--enable-pubsub-experiment'] + } } - }), { + )), { skip: isWindows ? [ // pubsub.subscribe { @@ -246,9 +232,9 @@ describe('interface-ipfs-core tests', () => { ] : null }) - tests.repo(defaultCommonFactory) + tests.repo(commonFactory) - tests.stats(defaultCommonFactory) + tests.stats(commonFactory) - tests.swarm(defaultCommonFactory) + tests.swarm(commonFactory) }) diff --git a/test/utils/interface-common-factory.js b/test/utils/interface-common-factory.js deleted file mode 100644 index bd4720b6e..000000000 --- a/test/utils/interface-common-factory.js +++ /dev/null @@ -1,92 +0,0 @@ -/* eslint-env mocha */ -'use strict' - -const each = require('async/each') -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 || { ...DEFAULT_FACTORY_OPTIONS } - options.spawnOptions = options.spawnOptions || { initOptions: { bits: 1024, profile: 'test' } } - - const ipfsFactory = IPFSFactory.create(options.factoryOptions) - - return function createCommon () { - const nodes = [] - let setup, teardown - - if (options.createSetup) { - setup = options.createSetup({ ipfsFactory, nodes }, options) - } else { - setup = (callback) => { - callback(null, { - spawnNode (cb) { - ipfsFactory.spawn(options.spawnOptions) - .then((ipfsd) => { - nodes.push(ipfsd) - setImmediate(() => cb(null, ipfsd.api)) - }) - .catch(err => { - setImmediate(() => cb(err)) - }) - } - }) - } - } - - if (options.createTeardown) { - teardown = options.createTeardown({ ipfsFactory, nodes }, options) - } else { - teardown = callback => each(nodes, (node, cb) => { - node - .stop() - .then(() => setImmediate(() => cb())) - .catch(err => setImmediate(() => cb(err))) - }, callback) - } - - return { setup, teardown } - } -} - -function createAsync (options = {}) { - return () => { - const nodes = [] - const setup = async (setupOptions = {}) => { - const ipfsFactory = IPFSFactory.create(merge( - options.factoryOptions ? {} : { ...DEFAULT_FACTORY_OPTIONS }, - setupOptions.factoryOptions, - options.factoryOptions - )) - const node = await ipfsFactory.spawn(merge( - setupOptions.spawnOptions, - options.spawnOptions || { initOptions: { profile: 'test' } } - )) - nodes.push(node) - - const id = await node.api.id() - node.api.peerId = id - - return node.api - } - - const teardown = () => { - return Promise.all(nodes.map(n => n.stop())) - } - return { - setup, - teardown - } - } -} -module.exports = { - createAsync, - create: createFactory -} From 73732a01c10f9678f6412370f6ab7f29f7304035 Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Fri, 11 Oct 2019 15:52:16 +0100 Subject: [PATCH 2/7] chore: add correct branches --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 791fe0a2b..a67959fd9 100644 --- a/package.json +++ b/package.json @@ -84,8 +84,8 @@ "cross-env": "^6.0.0", "detect-node": "^2.0.4", "go-ipfs-dep": "^0.4.22", - "interface-ipfs-core": "^0.124.0", - "ipfsd-ctl": "^0.47.1", + "interface-ipfs-core": "ipfs/interface-js-ipfs-core#feat/interface-tests", + "ipfsd-ctl": "ipfs/js-ipfsd-ctl#feat/interface-tests", "ndjson": "^1.5.0", "nock": "^11.4.0", "pull-stream": "^3.6.14", From 12bbf3439044f5750c2b622c542612a5cdb0c6a0 Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Wed, 4 Dec 2019 10:44:41 +0000 Subject: [PATCH 3/7] fix: support new ctl --- package.json | 4 ++-- test/commands.spec.js | 16 ++------------- test/constructor.spec.js | 12 +++--------- test/dag.spec.js | 16 ++------------- test/diag.spec.js | 16 ++------------- test/files-mfs.spec.js | 16 ++------------- test/get.spec.js | 17 ++-------------- test/interface.spec.js | 42 +++++++++++++++++++--------------------- test/key.spec.js | 16 ++------------- test/log.spec.js | 16 ++------------- test/ping.spec.js | 30 +++------------------------- test/repo.spec.js | 16 ++------------- test/stats.spec.js | 16 ++------------- test/utils/factory.js | 13 +++++++++++-- 14 files changed, 57 insertions(+), 189 deletions(-) diff --git a/package.json b/package.json index a67959fd9..c68dc88a0 100644 --- a/package.json +++ b/package.json @@ -84,8 +84,8 @@ "cross-env": "^6.0.0", "detect-node": "^2.0.4", "go-ipfs-dep": "^0.4.22", - "interface-ipfs-core": "ipfs/interface-js-ipfs-core#feat/interface-tests", - "ipfsd-ctl": "ipfs/js-ipfsd-ctl#feat/interface-tests", + "interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#feat/interface-tests", + "ipfsd-ctl": "github:ipfs/js-ipfsd-ctl#feat/interface-tests", "ndjson": "^1.5.0", "nock": "^11.4.0", "pull-stream": "^3.6.14", diff --git a/test/commands.spec.js b/test/commands.spec.js index 2f7b1f5e3..582ead76c 100644 --- a/test/commands.spec.js +++ b/test/commands.spec.js @@ -2,30 +2,18 @@ 'use strict' const { expect } = require('interface-ipfs-core/src/utils/mocha') -const ipfsClient = require('../src') const f = require('./utils/factory') describe('.commands', function () { this.timeout(60 * 1000) - let ipfsd let ipfs before(async () => { - ipfsd = await f.spawn({ - initOptions: { - bits: 1024, - profile: 'test' - } - }) - ipfs = ipfsClient(ipfsd.apiAddr) + ipfs = await f.setup() }) - after(async () => { - if (ipfsd) { - await ipfsd.stop() - } - }) + after(() => f.teardown()) it('lists commands', async () => { const res = await ipfs.commands() diff --git a/test/constructor.spec.js b/test/constructor.spec.js index 60bfc9f33..63b5c975b 100644 --- a/test/constructor.spec.js +++ b/test/constructor.spec.js @@ -93,24 +93,18 @@ describe('ipfs-http-client constructor tests', () => { }) describe('integration', () => { - let apiAddr let ipfsd before(async function () { this.timeout(60 * 1000) // slow CI - ipfsd = await f.spawn({ initOptions: { bits: 1024, profile: 'test' } }) - apiAddr = ipfsd.apiAddr.toString() + ipfsd = await f.node() }) - after(async () => { - if (ipfsd) { - await ipfsd.stop() - } - }) + after(() => ipfsd.stop()) it('can connect to an ipfs http api', async () => { - await clientWorks(ipfsClient(apiAddr)) + await clientWorks(ipfsClient(ipfsd.apiAddr)) }) }) }) diff --git a/test/dag.spec.js b/test/dag.spec.js index cd58002ad..09623dc64 100644 --- a/test/dag.spec.js +++ b/test/dag.spec.js @@ -6,29 +6,17 @@ const { expect } = require('interface-ipfs-core/src/utils/mocha') const { DAGNode } = require('ipld-dag-pb') const CID = require('cids') -const ipfsClient = require('../src') const f = require('./utils/factory') -let ipfsd let ipfs describe('.dag', function () { this.timeout(20 * 1000) before(async function () { - ipfsd = await f.spawn({ - initOptions: { - bits: 1024, - profile: 'test' - } - }) - ipfs = ipfsClient(ipfsd.apiAddr) + ipfs = await f.setup() }) - after(async () => { - if (ipfsd) { - await ipfsd.stop() - } - }) + after(() => f.teardown()) it('should be able to put and get a DAG node with format dag-pb', async () => { const data = Buffer.from('some data') diff --git a/test/diag.spec.js b/test/diag.spec.js index e42716214..3b3a1bd97 100644 --- a/test/diag.spec.js +++ b/test/diag.spec.js @@ -3,7 +3,6 @@ const { expect } = require('interface-ipfs-core/src/utils/mocha') const platform = require('browser-process-platform') -const ipfsClient = require('../src') const f = require('./utils/factory') describe('.diag', function () { @@ -12,24 +11,13 @@ describe('.diag', function () { // go-ipfs does not support these on Windows if (platform === 'win32') { return } - let ipfsd let ipfs before(async () => { - ipfsd = await f.spawn({ - initOptions: { - bits: 1024, - profile: 'test' - } - }) - ipfs = ipfsClient(ipfsd.apiAddr) + ipfs = await f.setup() }) - after(async () => { - if (ipfsd) { - await ipfsd.stop() - } - }) + after(() => f.teardown()) describe('api API', () => { // Disabled in go-ipfs 0.4.10 diff --git a/test/files-mfs.spec.js b/test/files-mfs.spec.js index 6ae508d1d..00dd20fa2 100644 --- a/test/files-mfs.spec.js +++ b/test/files-mfs.spec.js @@ -10,7 +10,6 @@ const values = require('pull-stream/sources/values') const pull = require('pull-stream/pull') const collect = require('pull-stream/sinks/collect') -const ipfsClient = require('../src') const f = require('./utils/factory') const expectTimeout = require('./utils/expect-timeout') @@ -31,26 +30,15 @@ const HASH_ALGS = [ describe('.files (the MFS API part)', function () { this.timeout(20 * 1000) - let ipfsd let ipfs const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' before(async () => { - ipfsd = await f.spawn({ - initOptions: { - bits: 1024, - profile: 'test' - } - }) - ipfs = ipfsClient(ipfsd.apiAddr) + ipfs = await f.setup() }) - after(async () => { - if (ipfsd) { - await ipfsd.stop() - } - }) + after(() => f.teardown()) it('.add file for testing', async () => { const res = await ipfs.add(testfile) diff --git a/test/get.spec.js b/test/get.spec.js index 7c1a63e74..009294a43 100644 --- a/test/get.spec.js +++ b/test/get.spec.js @@ -6,7 +6,6 @@ const { expect } = require('interface-ipfs-core/src/utils/mocha') const loadFixture = require('aegir/fixtures') -const ipfsClient = require('../src') const f = require('./utils/factory') describe('.get (specific go-ipfs features)', function () { @@ -21,26 +20,14 @@ describe('.get (specific go-ipfs features)', function () { data: fixture('test/fixtures/testfile.txt') } - let ipfsd let ipfs before(async () => { - ipfsd = await f.spawn({ - initOptions: { - bits: 1024, - profile: 'test' - } - }) - ipfs = ipfsClient(ipfsd.apiAddr) - + ipfs = await f.setup() await ipfs.add(smallFile.data) }) - after(async () => { - if (ipfsd) { - await ipfsd.stop() - } - }) + after(() => f.teardown()) it('no compression args', async () => { const files = await ipfs.get(smallFile.cid) diff --git a/test/interface.spec.js b/test/interface.spec.js index 7adb542e5..637abf3b4 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -4,14 +4,20 @@ const tests = require('interface-ipfs-core') const merge = require('merge-options') const { isNode } = require('ipfs-utils/src/env') -const ctl = require('ipfsd-ctl') +const { createTestsInterface } = require('ipfsd-ctl') const isWindows = process.platform && process.platform === 'win32' describe('interface-ipfs-core tests', () => { const commonOptions = { - factoryOptions: { IpfsClient: require('../src') } + ipfsHttp: { + path: require.resolve('../src'), + ref: require('../src') + }, + ipfsOptions: { + pass: 'ipfs-is-awesome-software' + } } - const commonFactory = ctl.createTestsInterface(commonOptions) + const commonFactory = createTestsInterface(commonOptions) tests.bitswap(commonFactory) @@ -144,20 +150,12 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.miscellaneous(commonFactory, { - skip: [ - // stop - { - name: 'should stop the node', - reason: 'FIXME go-ipfs returns an error https://github.com/ipfs/go-ipfs/issues/4078' - } - ] - }) + tests.miscellaneous(commonFactory) - tests.name(ctl.createTestsInterface(merge(commonOptions, + tests.name(createTestsInterface(merge(commonOptions, { - spawnOptions: { - args: ['--offline'] + ipfsOptions: { + offline: true } } )), { @@ -170,10 +168,12 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.namePubsub(ctl.createTestsInterface(merge(commonOptions, + tests.namePubsub(createTestsInterface(merge(commonOptions, { - spawnOptions: { - args: ['--enable-namesys-pubsub'] + ipfsOptions: { + EXPERIMENTAL: { + ipnsPubsub: true + } } } )), { @@ -212,11 +212,9 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.pubsub(ctl.createTestsInterface(merge(commonOptions, + tests.pubsub(createTestsInterface(merge(commonOptions, { - spawnOptions: { - args: ['--enable-pubsub-experiment'] - } + args: ['--enable-pubsub-experiment'] } )), { skip: isWindows ? [ diff --git a/test/key.spec.js b/test/key.spec.js index 2e4e15714..32d72b89a 100644 --- a/test/key.spec.js +++ b/test/key.spec.js @@ -3,30 +3,18 @@ 'use strict' const { expect } = require('interface-ipfs-core/src/utils/mocha') -const ipfsClient = require('../src') const f = require('./utils/factory') describe('.key', function () { this.timeout(50 * 1000) - let ipfsd let ipfs before(async () => { - ipfsd = await f.spawn({ - initOptions: { - bits: 1024, - profile: 'test' - } - }) - ipfs = ipfsClient(ipfsd.apiAddr) + ipfs = await f.setup() }) - after(async () => { - if (ipfsd) { - await ipfsd.stop() - } - }) + after(() => f.teardown()) describe('.gen', () => { it('create a new rsa key', async () => { diff --git a/test/log.spec.js b/test/log.spec.js index 7f8e2c608..730e60621 100644 --- a/test/log.spec.js +++ b/test/log.spec.js @@ -3,30 +3,18 @@ 'use strict' const { expect } = require('interface-ipfs-core/src/utils/mocha') -const ipfsClient = require('../src') const f = require('./utils/factory') describe('.log', function () { this.timeout(100 * 1000) - let ipfsd let ipfs before(async () => { - ipfsd = await f.spawn({ - initOptions: { - bits: 1024, - profile: 'test' - } - }) - ipfs = ipfsClient(ipfsd.apiAddr) + ipfs = await f.setup() }) - after(async () => { - if (ipfsd) { - await ipfsd.stop() - } - }) + after(() => f.teardown()) it('.log.tail', async () => { const i = setInterval(async () => { diff --git a/test/ping.spec.js b/test/ping.spec.js index 10c131b75..744a5ad62 100644 --- a/test/ping.spec.js +++ b/test/ping.spec.js @@ -5,7 +5,6 @@ const { expect } = require('interface-ipfs-core/src/utils/mocha') const pull = require('pull-stream/pull') const collect = require('pull-stream/sinks/collect') -const ipfsClient = require('../src') const f = require('./utils/factory') // Determine if a ping response object is a pong, or something else, like a status message @@ -17,29 +16,14 @@ describe('.ping', function () { this.timeout(20 * 1000) let ipfs - let ipfsd let other - let otherd let otherId before(async function () { this.timeout(30 * 1000) // slow CI - ipfsd = await f.spawn({ - initOptions: { - bits: 1024, - profile: 'test' - } - }) - ipfs = ipfsClient(ipfsd.apiAddr) - - otherd = await f.spawn({ - initOptions: { - bits: 1024, - profile: 'test' - } - }) - other = otherd.api + ipfs = await f.setup() + other = await f.setup() const ma = (await ipfs.id()).addresses[0] await other.swarm.connect(ma) @@ -47,15 +31,7 @@ describe('.ping', function () { otherId = (await other.id()).id }) - after(async () => { - if (ipfsd) { - await ipfsd.stop() - } - - if (otherd) { - await otherd.stop() - } - }) + after(() => f.teardown()) it('.ping with default count', async () => { const res = await ipfs.ping(otherId) diff --git a/test/repo.spec.js b/test/repo.spec.js index 84b5a42c3..b85074ab7 100644 --- a/test/repo.spec.js +++ b/test/repo.spec.js @@ -2,30 +2,18 @@ 'use strict' const { expect } = require('interface-ipfs-core/src/utils/mocha') -const ipfsClient = require('../src') const f = require('./utils/factory') describe('.repo', function () { this.timeout(50 * 1000) // slow CI let ipfs - let ipfsd before(async () => { - ipfsd = await f.spawn({ - initOptions: { - bits: 1024, - profile: 'test' - } - }) - ipfs = ipfsClient(ipfsd.apiAddr) + ipfs = await f.setup() }) - after(async () => { - if (ipfsd) { - await ipfsd.stop() - } - }) + after(() => f.teardown()) it('.repo.gc', async () => { const res = await ipfs.repo.gc() diff --git a/test/stats.spec.js b/test/stats.spec.js index 0b7084d0a..e3ec893d1 100644 --- a/test/stats.spec.js +++ b/test/stats.spec.js @@ -2,30 +2,18 @@ 'use strict' const { expect } = require('interface-ipfs-core/src/utils/mocha') -const ipfsClient = require('../src') const f = require('./utils/factory') describe('stats', function () { this.timeout(50 * 1000) // slow CI let ipfs - let ipfsd before(async () => { - ipfsd = await f.spawn({ - initOptions: { - bits: 1024, - profile: 'test' - } - }) - ipfs = ipfsClient(ipfsd.apiAddr) + ipfs = await f.setup() }) - after(async () => { - if (ipfsd) { - await ipfsd.stop() - } - }) + after(() => f.teardown()) it('.stats.bitswap', async () => { const res = await ipfs.stats.bitswap() diff --git a/test/utils/factory.js b/test/utils/factory.js index aab6296fe..d6113ab70 100644 --- a/test/utils/factory.js +++ b/test/utils/factory.js @@ -1,5 +1,14 @@ 'use strict' +const { createTestsInterface } = require('ipfsd-ctl') +const { findBin } = require('ipfsd-ctl/src/utils') -const IPFSFactory = require('ipfsd-ctl') +const factory = createTestsInterface({ + type: 'go', + ipfsBin: findBin('go'), + ipfsHttp: { + path: require.resolve('../../src'), + ref: require('../../src') + } +}) -module.exports = IPFSFactory.create() +module.exports = factory From b502af95a18bbd0bd343ab34c62373ab9916fde5 Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Mon, 9 Dec 2019 21:13:58 +0000 Subject: [PATCH 4/7] fix: update to the latest ctl api --- test/commands.spec.js | 4 ++-- test/constructor.spec.js | 4 ++-- test/dag.spec.js | 4 ++-- test/diag.spec.js | 4 ++-- test/files-mfs.spec.js | 4 ++-- test/get.spec.js | 4 ++-- test/interface.spec.js | 18 ++++++++++++------ test/key.spec.js | 5 ++--- test/log.spec.js | 4 ++-- test/ping.spec.js | 6 +++--- test/repo.spec.js | 4 ++-- test/stats.spec.js | 4 ++-- test/utils/factory.js | 5 +++-- 13 files changed, 38 insertions(+), 32 deletions(-) diff --git a/test/commands.spec.js b/test/commands.spec.js index 582ead76c..9e68a1e01 100644 --- a/test/commands.spec.js +++ b/test/commands.spec.js @@ -10,10 +10,10 @@ describe('.commands', function () { let ipfs before(async () => { - ipfs = await f.setup() + ipfs = (await f.spawn()).api }) - after(() => f.teardown()) + after(() => f.clean()) it('lists commands', async () => { const res = await ipfs.commands() diff --git a/test/constructor.spec.js b/test/constructor.spec.js index 63b5c975b..a1a000c84 100644 --- a/test/constructor.spec.js +++ b/test/constructor.spec.js @@ -98,10 +98,10 @@ describe('ipfs-http-client constructor tests', () => { before(async function () { this.timeout(60 * 1000) // slow CI - ipfsd = await f.node() + ipfsd = await f.spawn() }) - after(() => ipfsd.stop()) + after(() => f.clean()) it('can connect to an ipfs http api', async () => { await clientWorks(ipfsClient(ipfsd.apiAddr)) diff --git a/test/dag.spec.js b/test/dag.spec.js index 09623dc64..de9217d13 100644 --- a/test/dag.spec.js +++ b/test/dag.spec.js @@ -13,10 +13,10 @@ let ipfs describe('.dag', function () { this.timeout(20 * 1000) before(async function () { - ipfs = await f.setup() + ipfs = (await f.spawn()).api }) - after(() => f.teardown()) + after(() => f.clean()) it('should be able to put and get a DAG node with format dag-pb', async () => { const data = Buffer.from('some data') diff --git a/test/diag.spec.js b/test/diag.spec.js index 3b3a1bd97..37a1911e7 100644 --- a/test/diag.spec.js +++ b/test/diag.spec.js @@ -14,10 +14,10 @@ describe('.diag', function () { let ipfs before(async () => { - ipfs = await f.setup() + ipfs = (await f.spawn()).api }) - after(() => f.teardown()) + after(() => f.clean()) describe('api API', () => { // Disabled in go-ipfs 0.4.10 diff --git a/test/files-mfs.spec.js b/test/files-mfs.spec.js index 00dd20fa2..0e3d6b1af 100644 --- a/test/files-mfs.spec.js +++ b/test/files-mfs.spec.js @@ -35,10 +35,10 @@ describe('.files (the MFS API part)', function () { const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP' before(async () => { - ipfs = await f.setup() + ipfs = (await f.spawn()).api }) - after(() => f.teardown()) + after(() => f.clean()) it('.add file for testing', async () => { const res = await ipfs.add(testfile) diff --git a/test/get.spec.js b/test/get.spec.js index 009294a43..a6fb3aaa4 100644 --- a/test/get.spec.js +++ b/test/get.spec.js @@ -23,11 +23,11 @@ describe('.get (specific go-ipfs features)', function () { let ipfs before(async () => { - ipfs = await f.setup() + ipfs = (await f.spawn()).api await ipfs.add(smallFile.data) }) - after(() => f.teardown()) + after(() => f.clean()) it('no compression args', async () => { const files = await ipfs.get(smallFile.cid) diff --git a/test/interface.spec.js b/test/interface.spec.js index 637abf3b4..2dd156125 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -4,20 +4,26 @@ const tests = require('interface-ipfs-core') const merge = require('merge-options') const { isNode } = require('ipfs-utils/src/env') -const { createTestsInterface } = require('ipfsd-ctl') +const { createFactory } = require('ipfsd-ctl') +const { findBin } = require('ipfsd-ctl/src/utils') const isWindows = process.platform && process.platform === 'win32' +/** @typedef {import("ipfsd-ctl").ControllerOptions} ControllerOptions */ + describe('interface-ipfs-core tests', () => { + /** @type ControllerOptions */ const commonOptions = { + test: true, ipfsHttp: { path: require.resolve('../src'), ref: require('../src') }, ipfsOptions: { pass: 'ipfs-is-awesome-software' - } + }, + ipfsBin: findBin('go') } - const commonFactory = createTestsInterface(commonOptions) + const commonFactory = createFactory(commonOptions) tests.bitswap(commonFactory) @@ -152,7 +158,7 @@ describe('interface-ipfs-core tests', () => { tests.miscellaneous(commonFactory) - tests.name(createTestsInterface(merge(commonOptions, + tests.name(createFactory(merge(commonOptions, { ipfsOptions: { offline: true @@ -168,7 +174,7 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.namePubsub(createTestsInterface(merge(commonOptions, + tests.namePubsub(createFactory(merge(commonOptions, { ipfsOptions: { EXPERIMENTAL: { @@ -212,7 +218,7 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.pubsub(createTestsInterface(merge(commonOptions, + tests.pubsub(createFactory(merge(commonOptions, { args: ['--enable-pubsub-experiment'] } diff --git a/test/key.spec.js b/test/key.spec.js index 32d72b89a..180cb795b 100644 --- a/test/key.spec.js +++ b/test/key.spec.js @@ -1,5 +1,4 @@ /* eslint-env mocha */ -/* eslint max-nested-callbacks: ["error", 8] */ 'use strict' const { expect } = require('interface-ipfs-core/src/utils/mocha') @@ -11,10 +10,10 @@ describe('.key', function () { let ipfs before(async () => { - ipfs = await f.setup() + ipfs = (await f.spawn()).api }) - after(() => f.teardown()) + after(() => f.clean()) describe('.gen', () => { it('create a new rsa key', async () => { diff --git a/test/log.spec.js b/test/log.spec.js index 730e60621..1a885028d 100644 --- a/test/log.spec.js +++ b/test/log.spec.js @@ -11,10 +11,10 @@ describe('.log', function () { let ipfs before(async () => { - ipfs = await f.setup() + ipfs = (await f.spawn()).api }) - after(() => f.teardown()) + after(() => f.clean()) it('.log.tail', async () => { const i = setInterval(async () => { diff --git a/test/ping.spec.js b/test/ping.spec.js index 744a5ad62..01636ed60 100644 --- a/test/ping.spec.js +++ b/test/ping.spec.js @@ -22,8 +22,8 @@ describe('.ping', function () { before(async function () { this.timeout(30 * 1000) // slow CI - ipfs = await f.setup() - other = await f.setup() + ipfs = (await f.spawn()).api + other = (await f.spawn()).api const ma = (await ipfs.id()).addresses[0] await other.swarm.connect(ma) @@ -31,7 +31,7 @@ describe('.ping', function () { otherId = (await other.id()).id }) - after(() => f.teardown()) + after(() => f.clean()) it('.ping with default count', async () => { const res = await ipfs.ping(otherId) diff --git a/test/repo.spec.js b/test/repo.spec.js index b85074ab7..21482135d 100644 --- a/test/repo.spec.js +++ b/test/repo.spec.js @@ -10,10 +10,10 @@ describe('.repo', function () { let ipfs before(async () => { - ipfs = await f.setup() + ipfs = (await f.spawn()).api }) - after(() => f.teardown()) + after(() => f.clean()) it('.repo.gc', async () => { const res = await ipfs.repo.gc() diff --git a/test/stats.spec.js b/test/stats.spec.js index e3ec893d1..d60aaa330 100644 --- a/test/stats.spec.js +++ b/test/stats.spec.js @@ -10,10 +10,10 @@ describe('stats', function () { let ipfs before(async () => { - ipfs = await f.setup() + ipfs = (await f.spawn()).api }) - after(() => f.teardown()) + after(() => f.clean()) it('.stats.bitswap', async () => { const res = await ipfs.stats.bitswap() diff --git a/test/utils/factory.js b/test/utils/factory.js index d6113ab70..326e96180 100644 --- a/test/utils/factory.js +++ b/test/utils/factory.js @@ -1,8 +1,9 @@ 'use strict' -const { createTestsInterface } = require('ipfsd-ctl') +const { createFactory } = require('ipfsd-ctl') const { findBin } = require('ipfsd-ctl/src/utils') -const factory = createTestsInterface({ +const factory = createFactory({ + test: 'true', type: 'go', ipfsBin: findBin('go'), ipfsHttp: { From 1144845c9f48db5431f5c65cc5860f1c0f375cc4 Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Mon, 9 Dec 2019 21:41:06 +0000 Subject: [PATCH 5/7] fix: use proper module --- test/interface.spec.js | 2 +- test/utils/factory.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/interface.spec.js b/test/interface.spec.js index 2dd156125..52eb3c0cc 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -14,7 +14,7 @@ describe('interface-ipfs-core tests', () => { /** @type ControllerOptions */ const commonOptions = { test: true, - ipfsHttp: { + ipfsHttpModule: { path: require.resolve('../src'), ref: require('../src') }, diff --git a/test/utils/factory.js b/test/utils/factory.js index 326e96180..d6ac161ea 100644 --- a/test/utils/factory.js +++ b/test/utils/factory.js @@ -6,7 +6,7 @@ const factory = createFactory({ test: 'true', type: 'go', ipfsBin: findBin('go'), - ipfsHttp: { + ipfsHttpModule: { path: require.resolve('../../src'), ref: require('../../src') } From 320bf38e54c1ce17cc7894d2f2051adee93c6f93 Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Wed, 11 Dec 2019 02:52:19 +0000 Subject: [PATCH 6/7] fix: override properly --- test/interface.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/interface.spec.js b/test/interface.spec.js index 52eb3c0cc..5435518cf 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -218,11 +218,11 @@ describe('interface-ipfs-core tests', () => { ] }) - tests.pubsub(createFactory(merge(commonOptions, - { + tests.pubsub(createFactory(commonOptions, { + go: { args: ['--enable-pubsub-experiment'] } - )), { + }), { skip: isWindows ? [ // pubsub.subscribe { From 768a529a308e79eb99a8ce751b594ee5ab654eea Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Wed, 11 Dec 2019 17:39:24 +0000 Subject: [PATCH 7/7] chore: bump ipfsd-ctl, interface-core --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c68dc88a0..33f66d82e 100644 --- a/package.json +++ b/package.json @@ -84,8 +84,8 @@ "cross-env": "^6.0.0", "detect-node": "^2.0.4", "go-ipfs-dep": "^0.4.22", - "interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#feat/interface-tests", - "ipfsd-ctl": "github:ipfs/js-ipfsd-ctl#feat/interface-tests", + "interface-ipfs-core": "~0.125.0", + "ipfsd-ctl": "^1.0.0", "ndjson": "^1.5.0", "nock": "^11.4.0", "pull-stream": "^3.6.14",