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

Commit a2d3478

Browse files
committed
test: use the factory as a singleton
1 parent 1894216 commit a2d3478

31 files changed

+65
-140
lines changed

.aegir.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const createServer = require('ipfsd-ctl').createServer
44

5-
const server = createServer(30003)
5+
const server = createServer()
66

77
module.exports = {
88
karma: {

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"glob": false,
88
"fs": false,
99
"stream": "readable-stream",
10-
"http": "stream-http"
10+
"http": "stream-http",
11+
"ipfs-api": false,
12+
"ipfs": false
1113
},
1214
"scripts": {
1315
"test": "aegir test",

test/bitswap.spec.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ chai.use(dirtyChai)
88

99
const IPFSApi = require('../src')
1010

11-
const DaemonFactory = require('ipfsd-ctl')
11+
const f = require('./utils/factory')
1212

1313
describe('.bitswap', function () {
1414
this.timeout(20 * 1000) // slow CI
@@ -19,9 +19,7 @@ describe('.bitswap', function () {
1919
before(function (done) {
2020
this.timeout(20 * 1000) // slow CI
2121

22-
const df = DaemonFactory.create({remote: true, port: 30003})
23-
24-
df.spawn((err, _ipfsd) => {
22+
f.spawn((err, _ipfsd) => {
2523
expect(err).to.not.exist()
2624
ipfsd = _ipfsd
2725
ipfs = IPFSApi(_ipfsd.apiAddr)

test/bootstrap.spec.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ const expect = chai.expect
88
chai.use(dirtyChai)
99

1010
const IPFSApi = require('../src')
11-
12-
const DaemonFactory = require('ipfsd-ctl')
11+
const f = require('./utils/factory')
1312

1413
const invalidArg = 'this/Is/So/Invalid/'
1514
const validIp4 = '/ip4/104.236.176.52/tcp/4001/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z'
@@ -21,9 +20,7 @@ describe('.bootstrap', function () {
2120
let ipfs
2221

2322
before((done) => {
24-
const df = DaemonFactory.create({remote: true, port: 30003})
25-
26-
df.spawn((err, _ipfsd) => {
23+
f.spawn((err, _ipfsd) => {
2724
expect(err).to.not.exist()
2825
ipfsd = _ipfsd
2926
ipfs = IPFSApi(_ipfsd.apiAddr)

test/commands.spec.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ chai.use(dirtyChai)
88

99
const IPFSApi = require('../src')
1010

11-
const DaemonFactory = require('ipfsd-ctl')
11+
const f = require('./utils/factory')
1212

1313
describe('.commands', function () {
1414
this.timeout(20 * 1000)
@@ -17,9 +17,7 @@ describe('.commands', function () {
1717
let ipfs
1818

1919
before((done) => {
20-
const df = DaemonFactory.create({remote: true, port: 30003})
21-
22-
df.spawn((err, _ipfsd) => {
20+
f.spawn((err, _ipfsd) => {
2321
expect(err).to.not.exist()
2422
ipfsd = _ipfsd
2523
ipfs = IPFSApi(_ipfsd.apiAddr)

test/constructor.spec.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const dirtyChai = require('dirty-chai')
66
const expect = chai.expect
77
chai.use(dirtyChai)
88

9-
const DaemonFactory = require('ipfsd-ctl')
9+
const f = require('./utils/factory')
1010
const ipfsAPI = require('../src/index.js')
1111

1212
function clientWorks (client, done) {
@@ -27,9 +27,7 @@ describe('ipfs-api constructor tests', () => {
2727
before(function (done) {
2828
this.timeout(20 * 1000) // slow CI
2929

30-
const df = DaemonFactory.create({remote: true, port: 30003})
31-
32-
df.spawn((err, node) => {
30+
f.spawn((err, node) => {
3331
expect(err).to.not.exist()
3432
ipfsd = node
3533
apiAddr = node.apiAddr.toString()

test/diag.spec.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ chai.use(dirtyChai)
88
const os = require('os')
99

1010
const IPFSApi = require('../src')
11-
12-
const DaemonFactory = require('ipfsd-ctl')
11+
const f = require('./utils/factory')
1312

1413
describe('.diag', function () {
1514
this.timeout(50 * 1000)
@@ -21,9 +20,7 @@ describe('.diag', function () {
2120
let ipfs
2221

2322
before((done) => {
24-
const df = DaemonFactory.create({remote: true, port: 30003})
25-
26-
df.spawn((err, _ipfsd) => {
23+
f.spawn((err, _ipfsd) => {
2724
expect(err).to.not.exist()
2825
ipfsd = _ipfsd
2926
ipfs = IPFSApi(_ipfsd.apiAddr)

test/files.spec.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ const mh = require('multihashes')
1212
const CID = require('cids')
1313

1414
const IPFSApi = require('../src')
15-
16-
const DaemonFactory = require('ipfsd-ctl')
15+
const f = require('./utils/factory')
1716

1817
const testfile = isNode
1918
? loadFixture(__dirname, '/fixtures/testfile.txt')
@@ -40,9 +39,7 @@ describe('.files (the MFS API part)', function () {
4039
const expectedMultihash = 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP'
4140

4241
before((done) => {
43-
const df = DaemonFactory.create({remote: true, port: 30003})
44-
45-
df.spawn((err, _ipfsd) => {
42+
f.spawn((err, _ipfsd) => {
4643
expect(err).to.not.exist()
4744
ipfsd = _ipfsd
4845
ipfs = IPFSApi(_ipfsd.apiAddr)

test/get.spec.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ const series = require('async/series')
1212
const loadFixture = require('aegir/fixtures')
1313

1414
const IPFSApi = require('../src')
15-
16-
const DaemonFactory = require('ipfsd-ctl')
17-
const df = DaemonFactory.create()
15+
const f = require('./utils/factory')
1816

1917
describe('.get (specific go-ipfs features)', function () {
2018
this.timeout(20 * 1000)
@@ -33,7 +31,7 @@ describe('.get (specific go-ipfs features)', function () {
3331

3432
before((done) => {
3533
series([
36-
(cb) => df.spawn((err, _ipfsd) => {
34+
(cb) => f.spawn((err, _ipfsd) => {
3735
expect(err).to.not.exist()
3836
ipfsd = _ipfsd
3937
ipfs = IPFSApi(_ipfsd.apiAddr)

test/interface/block.spec.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@ const test = require('interface-ipfs-core')
66
const parallel = require('async/parallel')
77

88
const IPFSApi = require('../../src')
9-
10-
const DaemonFactory = require('ipfsd-ctl')
9+
const f = require('../utils/factory')
1110

1211
const nodes = []
1312
const common = {
1413
setup: function (callback) {
15-
const df = DaemonFactory.create({remote: true, port: 30003})
16-
1714
callback(null, {
1815
spawnNode: (cb) => {
19-
df.spawn((err, _ipfsd) => {
16+
f.spawn((err, _ipfsd) => {
2017
if (err) {
2118
return cb(err)
2219
}

test/interface/config.spec.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@ const test = require('interface-ipfs-core')
66
const parallel = require('async/parallel')
77

88
const IPFSApi = require('../../src')
9-
10-
const DaemonFactory = require('ipfsd-ctl')
9+
const f = require('../utils/factory')
1110

1211
const nodes = []
1312
const common = {
1413
setup: function (callback) {
15-
const df = DaemonFactory.create({remote: true, port: 30003})
16-
1714
callback(null, {
1815
spawnNode: (cb) => {
19-
df.spawn((err, _ipfsd) => {
16+
f.spawn((err, _ipfsd) => {
2017
if (err) {
2118
return cb(err)
2219
}

test/interface/dht.spec.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@ const test = require('interface-ipfs-core')
55
const parallel = require('async/parallel')
66

77
const IPFSApi = require('../../src')
8-
9-
const DaemonFactory = require('ipfsd-ctl')
8+
const f = require('../utils/factory')
109

1110
const nodes = []
1211
const common = {
1312
setup: function (callback) {
14-
const df = DaemonFactory.create({remote: true, port: 30003})
15-
1613
callback(null, {
1714
spawnNode: (cb) => {
18-
df.spawn((err, _ipfsd) => {
15+
f.spawn((err, _ipfsd) => {
1916
if (err) {
2017
return cb(err)
2118
}

test/interface/files.spec.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@ const test = require('interface-ipfs-core')
66
const parallel = require('async/parallel')
77

88
const IPFSApi = require('../../src')
9-
10-
const DaemonFactory = require('ipfsd-ctl')
9+
const f = require('../utils/factory')
1110

1211
const nodes = []
1312
const common = {
1413
setup: function (callback) {
15-
const df = DaemonFactory.create({remote: true, port: 30003})
16-
1714
callback(null, {
1815
spawnNode: (cb) => {
19-
df.spawn((err, _ipfsd) => {
16+
f.spawn((err, _ipfsd) => {
2017
if (err) {
2118
return cb(err)
2219
}

test/interface/key.spec.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@ const test = require('interface-ipfs-core')
66
const parallel = require('async/parallel')
77

88
const IPFSApi = require('../../src')
9-
10-
const DaemonFactory = require('ipfsd-ctl')
9+
const f = require('../utils/factory')
1110

1211
const nodes = []
1312
const common = {
1413
setup: function (callback) {
15-
const df = DaemonFactory.create({remote: true, port: 30003})
16-
1714
callback(null, {
1815
spawnNode: (cb) => {
19-
df.spawn((err, _ipfsd) => {
16+
f.spawn((err, _ipfsd) => {
2017
if (err) {
2118
return cb(err)
2219
}

test/interface/miscellaneous.spec.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,14 @@
55
const test = require('interface-ipfs-core')
66

77
const IPFSApi = require('../../src')
8-
9-
const DaemonFactory = require('ipfsd-ctl')
8+
const f = require('../utils/factory')
109

1110
const nodes = []
1211
const common = {
1312
setup: function (callback) {
14-
const df = DaemonFactory.create({remote: true, port: 30003})
15-
1613
callback(null, {
1714
spawnNode: (cb) => {
18-
df.spawn((err, _ipfsd) => {
15+
f.spawn((err, _ipfsd) => {
1916
if (err) {
2017
return cb(err)
2118
}

test/interface/object.spec.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@ const test = require('interface-ipfs-core')
66
const parallel = require('async/parallel')
77

88
const IPFSApi = require('../../src')
9-
10-
const DaemonFactory = require('ipfsd-ctl')
9+
const f = require('../utils/factory')
1110

1211
const nodes = []
1312
const common = {
1413
setup: function (callback) {
15-
const df = DaemonFactory.create({remote: true, port: 30003})
16-
1714
callback(null, {
1815
spawnNode: (cb) => {
19-
df.spawn((err, _ipfsd) => {
16+
f.spawn((err, _ipfsd) => {
2017
if (err) {
2118
return cb(err)
2219
}

test/interface/pin.spec.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@ const test = require('interface-ipfs-core')
66
const parallel = require('async/parallel')
77

88
const IPFSApi = require('../../src')
9-
10-
const DaemonFactory = require('ipfsd-ctl')
9+
const f = require('../utils/factory')
1110

1211
const nodes = []
1312
const common = {
1413
setup: function (callback) {
15-
const df = DaemonFactory.create({remote: true, port: 30003})
16-
1714
callback(null, {
1815
spawnNode: (cb) => {
19-
df.spawn((err, _ipfsd) => {
16+
f.spawn((err, _ipfsd) => {
2017
if (err) {
2118
return cb(err)
2219
}

test/interface/pubsub.spec.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,15 @@ const isNode = require('detect-node')
88
const parallel = require('async/parallel')
99

1010
const IPFSApi = require('../../src')
11-
12-
const DaemonFactory = require('ipfsd-ctl')
11+
const f = require('../utils/factory')
1312

1413
if (isNode) {
1514
const nodes = []
1615
const common = {
1716
setup: function (callback) {
18-
const df = DaemonFactory.create({remote: true, port: 30003})
19-
2017
callback(null, {
2118
spawnNode: (cb) => {
22-
df.spawn({ args: ['--enable-pubsub-experiment'] },
19+
f.spawn({ args: ['--enable-pubsub-experiment'] },
2320
(err, _ipfsd) => {
2421
if (err) {
2522
return cb(err)

test/interface/repo.spec.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@ const test = require('interface-ipfs-core')
66
const parallel = require('async/parallel')
77

88
const IPFSApi = require('../../src')
9-
10-
const DaemonFactory = require('ipfsd-ctl')
9+
const f = require('../utils/factory')
1110

1211
const nodes = []
1312
const common = {
1413
setup: function (callback) {
15-
const df = DaemonFactory.create({remote: true, port: 30003})
16-
1714
callback(null, {
1815
spawnNode: (cb) => {
19-
df.spawn((err, _ipfsd) => {
16+
f.spawn((err, _ipfsd) => {
2017
if (err) {
2118
return cb(err)
2219
}

test/interface/stats.spec.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@ const test = require('interface-ipfs-core')
66
const parallel = require('async/parallel')
77

88
const IPFSApi = require('../../src')
9-
10-
const DaemonFactory = require('ipfsd-ctl')
9+
const f = require('../utils/factory')
1110

1211
const nodes = []
1312
const common = {
1413
setup: function (callback) {
15-
const df = DaemonFactory.create({remote: true, port: 30003})
16-
1714
callback(null, {
1815
spawnNode: (cb) => {
19-
df.spawn((err, _ipfsd) => {
16+
f.spawn((err, _ipfsd) => {
2017
if (err) {
2118
return cb(err)
2219
}

0 commit comments

Comments
 (0)