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

feat: use new ipfsd-ctl #652

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .aegir.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
'use strict'

const factory = require('./test/ipfs-factory/tasks')
const createServer = require('ipfsd-ctl').createServer

const server = createServer()
module.exports = {
karma: {
files: [{
pattern: 'node_modules/interface-ipfs-core/test/fixtures/**/*',
watched: false,
served: true,
included: false
}]
}],
singleRun: true
},
hooks: {
pre: factory.start,
post: factory.stop
pre: server.start.bind(server),
post: server.stop.bind(server)
}
}
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
"http": "stream-http"
},
"scripts": {
"test": "aegir test ",
"test:node": "aegir test -t node ",
"test": "aegir test",
"test:node": "aegir test -t node",
"test:browser": "aegir test -t browser",
"test:webworker": "aegir test -t webworker",
"lint": "aegir lint",
"build": "aegir build",
"release": "aegir release ",
Expand Down Expand Up @@ -65,10 +66,11 @@
"chai": "^4.1.2",
"dirty-chai": "^2.0.1",
"eslint-plugin-react": "^7.5.1",
"go-ipfs-dep": "^0.4.13",
"gulp": "^3.9.1",
"interface-ipfs-core": "~0.40.0",
"interface-ipfs-core": "~0.41.0",
"hapi": "^16.6.2",
"ipfsd-ctl": "~0.26.0",
"ipfsd-ctl": "~0.27.0",
"pre-commit": "^1.2.2",
"socket.io": "^2.0.4",
"socket.io-client": "^2.0.4",
Expand Down
16 changes: 8 additions & 8 deletions test/bitswap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const FactoryClient = require('./ipfs-factory/client')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

describe('.bitswap', function () {
this.timeout(20 * 1000) // slow CI
let ipfs
let fc
let ipfsd = null

before((done) => {
this.timeout(20 * 1000) // slow CI
fc = new FactoryClient()
fc.spawnNode((err, node) => {
df.spawn((err, node) => {
expect(err).to.not.exist()
ipfs = node
ipfsd = node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace this line by: ipfs = ipfsd.api and avoid replacing all the other lines.

ipfs = node.api
done()
})
})

after((done) => {
fc.dismantle(done)
})
after((done) => ipfsd.stop(done))

describe('Callback API', () => {
it('.wantlist', (done) => {
Expand Down
16 changes: 8 additions & 8 deletions test/bootstrap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const FactoryClient = require('./ipfs-factory/client')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

const invalidArg = 'this/Is/So/Invalid/'
const validIp4 = '/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z'

describe('.bootstrap', function () {
this.timeout(100 * 1000)

let ipfsd
let ipfs
let fc

before((done) => {
fc = new FactoryClient()
fc.spawnNode((err, node) => {
df.spawn((err, node) => {
expect(err).to.not.exist()
ipfs = node
ipfsd = node
ipfs = node.api
done()
})
})

after((done) => {
fc.dismantle(done)
})
after((done) => ipfsd.stop(done))

let peers

Expand Down
15 changes: 7 additions & 8 deletions test/commands.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,25 @@ const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)

const FactoryClient = require('./ipfs-factory/client')
const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

describe('.commands', function () {
this.timeout(20 * 1000)

let ipfsd
let ipfs
let fc

before((done) => {
fc = new FactoryClient()
fc.spawnNode((err, node) => {
df.spawn((err, node) => {
expect(err).to.not.exist()
ipfs = node
ipfsd = node
ipfs = node.api
done()
})
})

after((done) => {
fc.dismantle(done)
})
after((done) => ipfsd.stop(done))

it('lists commands', (done) => {
ipfs.commands((err, res) => {
Expand Down
14 changes: 8 additions & 6 deletions test/constructor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const FactoryClient = require('./ipfs-factory/client')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

const ipfsAPI = require('../src/index.js')

Expand All @@ -22,19 +24,19 @@ function clientWorks (client, done) {
describe('ipfs-api constructor tests', () => {
describe('parameter permuations', () => {
let apiAddr
let fc
let ipfsd

before(function (done) {
this.timeout(20 * 1000) // slow CI
fc = new FactoryClient()
fc.spawnNode((err, node) => {
df.spawn((err, node) => {
expect(err).to.not.exist()
apiAddr = node.apiAddr
ipfsd = node
apiAddr = node.apiAddr.toString()
done()
})
})

after((done) => fc.dismantle(done))
after((done) => ipfsd.stop(done))

it('opts', (done) => {
const splitted = apiAddr.split('/')
Expand Down
14 changes: 8 additions & 6 deletions test/diag.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
/* eslint-env mocha */
'use strict'

const FactoryClient = require('./ipfs-factory/client')
const chai = require('chai')
const dirtyChai = require('dirty-chai')
const expect = chai.expect
chai.use(dirtyChai)
const os = require('os')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

describe('.diag', function () {
this.timeout(50 * 1000)

Expand All @@ -16,19 +18,19 @@ describe('.diag', function () {
return
}

let ipfsd
let ipfs
let fc

before((done) => {
fc = new FactoryClient()
fc.spawnNode((err, node) => {
df.spawn((err, node) => {
expect(err).to.not.exist()
ipfs = node
ipfsd = node
ipfs = node.api
done()
})
})

after((done) => fc.dismantle(done))
after((done) => ipfsd.stop(done))

describe('Callback API', () => {
// Disabled in go-ipfs 0.4.10
Expand Down
13 changes: 7 additions & 6 deletions test/files.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const loadFixture = require('aegir/fixtures')
const mh = require('multihashes')
const CID = require('cids')

const FactoryClient = require('./ipfs-factory/client')
const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

const testfile = isNode
? loadFixture(__dirname, '/fixtures/testfile.txt')
Expand All @@ -32,21 +33,21 @@ const HASH_ALGS = [
describe('.files (the MFS API part)', function () {
this.timeout(120 * 1000)

let ipfsd
let ipfs
let fc

const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'

before((done) => {
fc = new FactoryClient()
fc.spawnNode((err, node) => {
df.spawn((err, node) => {
expect(err).to.not.exist()
ipfs = node
ipfsd = node
ipfs = node.api
done()
})
})

after((done) => fc.dismantle(done))
after((done) => ipfsd.stop(done))

describe('Callback API', function () {
this.timeout(120 * 1000)
Expand Down
17 changes: 9 additions & 8 deletions test/get.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ chai.use(dirtyChai)
const isNode = require('detect-node')
const series = require('async/series')
const loadFixture = require('aegir/fixtures')
const FactoryClient = require('./ipfs-factory/client')

const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

describe('.get (specific go-ipfs features)', function () {
this.timeout(20 * 1000)
Expand All @@ -24,23 +26,22 @@ describe('.get (specific go-ipfs features)', function () {
data: fixture('../test/fixtures/testfile.txt')
}

let ipfsd
let ipfs
let fc

before((done) => {
fc = new FactoryClient()

series([
(cb) => fc.spawnNode((err, node) => {
(cb) => df.spawn((err, node) => {
expect(err).to.not.exist()
ipfs = node
ipfsd = node
ipfs = node.api
cb()
}),
(cb) => ipfs.files.add(smallFile.data, cb)
(cb) => ipfsd.api.files.add(smallFile.data, cb)
], done)
})

after((done) => fc.dismantle(done))
after((done) => ipfsd.stop(done))

it('no compression args', (done) => {
ipfs.get(smallFile.cid, (err, files) => {
Expand Down
10 changes: 3 additions & 7 deletions test/interface/block.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
'use strict'

const test = require('interface-ipfs-core')
const Factory = require('../ipfs-factory/client')

let factory
const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

const common = {
setup: function (callback) {
factory = new Factory()
callback(null, factory)
},
teardown: function (callback) {
factory.dismantle(callback)
callback(null, df)
}
}

Expand Down
10 changes: 3 additions & 7 deletions test/interface/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@
'use strict'

const test = require('interface-ipfs-core')
const FactoryClient = require('../ipfs-factory/client')

let fc
const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

const common = {
setup: function (callback) {
fc = new FactoryClient()
callback(null, fc)
},
teardown: function (callback) {
fc.dismantle(callback)
callback(null, df)
}
}

Expand Down
10 changes: 3 additions & 7 deletions test/interface/dht.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@
'use strict'

const test = require('interface-ipfs-core')
const FactoryClient = require('../ipfs-factory/client')

let fc
const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

const common = {
setup: function (callback) {
fc = new FactoryClient()
callback(null, fc)
},
teardown: function (callback) {
fc.dismantle(callback)
callback(null, df)
}
}

Expand Down
11 changes: 3 additions & 8 deletions test/interface/files.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@

const test = require('interface-ipfs-core')

const FactoryClient = require('../ipfs-factory/client')

let fc
const DaemonFactory = require('ipfsd-ctl')
const df = DaemonFactory.create()

const common = {
setup: function (callback) {
fc = new FactoryClient()
callback(null, fc)
},
teardown: function (callback) {
fc.dismantle(callback)
callback(null, df)
}
}

Expand Down
Loading