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

Commit a3c134d

Browse files
committed
feat: allow passing daemon type and exec path to spawn
1 parent 2545586 commit a3c134d

File tree

11 files changed

+48
-28
lines changed

11 files changed

+48
-28
lines changed

src/block.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ module.exports = (common) => {
2727
// timeout for the before step
2828
this.timeout(60 * 1000)
2929

30-
common.setup((err, df) => {
30+
common.setup((err, df, type, exec) => {
3131
expect(err).to.not.exist()
32-
df.spawn((err, node) => {
32+
df.spawn({ type, exec }, (err, node) => {
3333
expect(err).to.not.exist()
3434
ipfsd = node
3535
ipfs = node.api

src/config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ module.exports = (common) => {
1919
// timeout for the before step
2020
this.timeout(60 * 1000)
2121

22-
common.setup((err, df) => {
22+
common.setup((err, df, type, exec) => {
2323
expect(err).to.not.exist()
24-
df.spawn((err, node) => {
24+
df.spawn({ type, exec }, (err, node) => {
2525
expect(err).to.not.exist()
2626
ipfsd = node
2727
ipfs = node.api

src/dag.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ module.exports = (common) => {
2424
// timeout for the before step
2525
this.timeout(60 * 1000)
2626

27-
common.setup((err, df) => {
27+
common.setup((err, df, type, exec) => {
2828
expect(err).to.not.exist()
29-
df.spawn((err, node) => {
29+
df.spawn({ type, exec }, (err, node) => {
3030
expect(err).to.not.exist()
3131
ipfs = node.api
3232
ipfsd = node

src/dht.js

+16-6
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,19 @@ const series = require('async/series')
1010
const parallel = require('async/parallel')
1111
const CID = require('cids')
1212

13-
function spawnWithId (df, callback) {
13+
function spawnWithId (df, type, exec, callback) {
14+
if (typeof type === 'function') {
15+
callback = type
16+
type = undefined
17+
}
18+
19+
if (typeof exec === 'function') {
20+
callback = exec
21+
exec = undefined
22+
}
23+
1424
waterfall([
15-
(cb) => df.spawn(cb),
25+
(cb) => df.spawn({ type, exec }, cb),
1626
(node, cb) => node.api.id((err, peerId) => {
1727
if (err) {
1828
return cb(err)
@@ -37,12 +47,12 @@ module.exports = (common) => {
3747
// timeout for the before step
3848
this.timeout(60 * 1000)
3949

40-
common.setup((err, factory) => {
50+
common.setup((err, df, type) => {
4151
expect(err).to.not.exist()
4252
series([
43-
(cb) => spawnWithId(factory, cb),
44-
(cb) => spawnWithId(factory, cb),
45-
(cb) => spawnWithId(factory, cb)
53+
(cb) => spawnWithId(df, type, cb),
54+
(cb) => spawnWithId(df, type, cb),
55+
(cb) => spawnWithId(df, type, cb)
4656
], (err, nodes) => {
4757
expect(err).to.not.exist()
4858

src/files.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ module.exports = (common) => {
5656
// timeout for the before step
5757
this.timeout(60 * 1000)
5858

59-
common.setup((err, fd) => {
59+
common.setup((err, df, type, exec) => {
6060
expect(err).to.not.exist()
61-
fd.spawn((err, node) => {
61+
df.spawn({ type, exec }, (err, node) => {
6262
expect(err).to.not.exist()
6363
ipfs = node.api
6464
ipfsd = node

src/key.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const hat = require('hat')
1212
module.exports = (common) => {
1313
describe('.key', () => {
1414
const keyTypes = [
15-
{type: 'rsa', size: 2048}
15+
{ type: 'rsa', size: 2048 }
1616
]
1717
const keys = []
1818
let ipfs
@@ -24,9 +24,9 @@ module.exports = (common) => {
2424
// timeout for the before step
2525
this.timeout(60 * 1000)
2626

27-
common.setup((err, df) => {
27+
common.setup((err, df, type, exec) => {
2828
expect(err).to.not.exist()
29-
df.spawn((err, node) => {
29+
df.spawn({ type, exec }, (err, node) => {
3030
expect(err).to.not.exist()
3131
ipfsd = node
3232
ipfs = node.api

src/miscellaneous.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ module.exports = (common) => {
1818
// timeout for the before step
1919
this.timeout(60 * 1000)
2020

21-
common.setup((err, df) => {
21+
common.setup((err, df, type, exec) => {
2222
expect(err).to.not.exist()
23-
df.spawn((err, node) => {
23+
df.spawn({ type, exec }, (err, node) => {
2424
expect(err).to.not.exist()
2525
ipfs = node.api
2626
ipfsd = node

src/object.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ module.exports = (common) => {
2424
// timeout for the before step
2525
this.timeout(60 * 1000)
2626

27-
common.setup((err, df) => {
27+
common.setup((err, df, type, exec) => {
2828
expect(err).to.not.exist()
29-
df.spawn((err, node) => {
29+
df.spawn({ type, exec }, (err, node) => {
3030
expect(err).to.not.exist()
3131
ipfs = node.api
3232
ipfsd = node
@@ -843,7 +843,7 @@ module.exports = (common) => {
843843
return ipfs.object.put(testObj, (err, node) => {
844844
expect(err).to.not.exist()
845845

846-
return ipfs.object.stat('QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ', {enc: 'base58'})
846+
return ipfs.object.stat('QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ', { enc: 'base58' })
847847
.then((stats) => {
848848
const expected = {
849849
Hash: 'QmNggDXca24S6cMPEYHZjeuc4QRmofkRrAEqVL3Ms2sdJZ',

src/pin.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ module.exports = (common) => {
2424
// timeout for the before step
2525
this.timeout(60 * 1000)
2626

27-
common.setup((err, df) => {
27+
common.setup((err, df, type, exec) => {
2828
expect(err).to.not.exist()
29-
df.spawn((err, node) => {
29+
df.spawn({ type, exec }, (err, node) => {
3030
expect(err).to.not.exist()
3131
ipfs = node.api
3232
ipfsd = node

src/pubsub.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,19 @@ function waitForPeers (ipfs, topic, peersToWait, callback) {
3232
}, 500)
3333
}
3434

35-
function spawnWithId (df, callback) {
35+
function spawnWithId (df, type, exec, callback) {
36+
if (typeof type === 'function') {
37+
callback = type
38+
type = undefined
39+
}
40+
41+
if (typeof exec === 'function') {
42+
callback = exec
43+
exec = undefined
44+
}
45+
3646
waterfall([
37-
(cb) => df.spawn({ args: ['--enable-pubsub-experiment'] }, cb),
47+
(cb) => df.spawn({ type, exec, args: ['--enable-pubsub-experiment'] }, cb),
3848
(node, cb) => node.api.id((err, res) => {
3949
if (err) {
4050
return cb(err)

src/swarm.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ module.exports = (common) => {
2828
// timeout for the before step
2929
this.timeout(100 * 1000)
3030

31-
common.setup((err, df) => {
31+
common.setup((err, df, type, exec) => {
3232
expect(err).to.not.exist()
3333
dfInstance = df
3434
series([
35-
(cb) => df.spawn((err, node) => {
35+
(cb) => df.spawn({ type, exec }, (err, node) => {
3636
expect(err).to.not.exist()
3737
ipfsA = node.api
3838
nodes.push(node)

0 commit comments

Comments
 (0)