From b502af95a18bbd0bd343ab34c62373ab9916fde5 Mon Sep 17 00:00:00 2001 From: Hugo Dias Date: Mon, 9 Dec 2019 21:13:58 +0000 Subject: [PATCH] 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: {