Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
fix: support new ctl
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias committed Dec 10, 2019
1 parent 73732a0 commit 12bbf34
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 189 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 2 additions & 14 deletions test/commands.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
12 changes: 3 additions & 9 deletions test/constructor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
})
})
Expand Down
16 changes: 2 additions & 14 deletions test/dag.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
16 changes: 2 additions & 14 deletions test/diag.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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
Expand Down
16 changes: 2 additions & 14 deletions test/files-mfs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand All @@ -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)
Expand Down
17 changes: 2 additions & 15 deletions test/get.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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)
Expand Down
42 changes: 20 additions & 22 deletions test/interface.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
}
}
)), {
Expand All @@ -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
}
}
}
)), {
Expand Down Expand Up @@ -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 ? [
Expand Down
16 changes: 2 additions & 14 deletions test/key.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
16 changes: 2 additions & 14 deletions test/log.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Loading

0 comments on commit 12bbf34

Please sign in to comment.