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

Commit 43f4891

Browse files
committed
feat: destroy multiple nodes
1 parent d32b03d commit 43f4891

10 files changed

+58
-37
lines changed

test/interface/block.spec.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
'use strict'
44

55
const test = require('interface-ipfs-core')
6+
const parallel = require('async/parallel')
7+
68
const IPFSApi = require('../../src')
79

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

11-
let ipfsd = null
13+
const nodes = []
1214
const common = {
1315
setup: function (callback) {
1416
callback(null, {
@@ -18,14 +20,14 @@ const common = {
1820
return cb(err)
1921
}
2022

21-
ipfsd = _ipfsd
23+
nodes.push(_ipfsd)
2224
cb(null, IPFSApi(_ipfsd.apiAddr))
2325
})
2426
}
2527
})
2628
},
2729
teardown: function (callback) {
28-
ipfsd.stop(callback)
30+
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
2931
}
3032
}
3133

test/interface/config.spec.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
'use strict'
44

55
const test = require('interface-ipfs-core')
6+
const parallel = require('async/parallel')
7+
68
const IPFSApi = require('../../src')
79

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

11-
let ipfsd = null
13+
const nodes = []
1214
const common = {
1315
setup: function (callback) {
1416
callback(null, {
@@ -18,14 +20,14 @@ const common = {
1820
return cb(err)
1921
}
2022

21-
ipfsd = _ipfsd
23+
nodes.push(_ipfsd)
2224
cb(null, IPFSApi(_ipfsd.apiAddr))
2325
})
2426
}
2527
})
2628
},
2729
teardown: function (callback) {
28-
ipfsd.stop(callback)
30+
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
2931
}
3032
}
3133

test/interface/dht.spec.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
'use strict'
33

44
const test = require('interface-ipfs-core')
5+
const parallel = require('async/parallel')
6+
57
const IPFSApi = require('../../src')
68

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

10-
let ipfsd = null
12+
const nodes = []
1113
const common = {
1214
setup: function (callback) {
1315
callback(null, {
@@ -17,14 +19,14 @@ const common = {
1719
return cb(err)
1820
}
1921

20-
ipfsd = _ipfsd
22+
nodes.push(_ipfsd)
2123
cb(null, IPFSApi(_ipfsd.apiAddr))
2224
})
2325
}
2426
})
2527
},
2628
teardown: function (callback) {
27-
ipfsd.stop(callback)
29+
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
2830
}
2931
}
3032

test/interface/files.spec.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
'use strict'
44

55
const test = require('interface-ipfs-core')
6+
const parallel = require('async/parallel')
7+
68
const IPFSApi = require('../../src')
79

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

11-
let ipfsd = null
13+
const nodes = []
1214
const common = {
1315
setup: function (callback) {
1416
callback(null, {
@@ -18,14 +20,14 @@ const common = {
1820
return cb(err)
1921
}
2022

21-
ipfsd = _ipfsd
23+
nodes.push(_ipfsd)
2224
cb(null, IPFSApi(_ipfsd.apiAddr))
2325
})
2426
}
2527
})
2628
},
2729
teardown: function (callback) {
28-
ipfsd.stop(callback)
30+
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
2931
}
3032
}
3133

test/interface/generic.spec.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
'use strict'
44

55
const test = require('interface-ipfs-core')
6+
const parallel = require('async/parallel')
7+
68
const IPFSApi = require('../../src')
79

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

11-
let ipfsd = null
13+
const nodes = []
1214
const common = {
1315
setup: function (callback) {
1416
callback(null, {
@@ -18,14 +20,14 @@ const common = {
1820
return cb(err)
1921
}
2022

21-
ipfsd = _ipfsd
23+
nodes.push(_ipfsd)
2224
cb(null, IPFSApi(_ipfsd.apiAddr))
2325
})
2426
}
2527
})
2628
},
2729
teardown: function (callback) {
28-
ipfsd.stop(callback)
30+
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
2931
}
3032
}
3133

test/interface/key.spec.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
'use strict'
44

55
const test = require('interface-ipfs-core')
6+
const parallel = require('async/parallel')
7+
68
const IPFSApi = require('../../src')
79

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

11-
let ipfsd = null
13+
const nodes = []
1214
const common = {
1315
setup: function (callback) {
1416
callback(null, {
@@ -18,14 +20,14 @@ const common = {
1820
return cb(err)
1921
}
2022

21-
ipfsd = _ipfsd
23+
nodes.push(_ipfsd)
2224
cb(null, IPFSApi(_ipfsd.apiAddr))
2325
})
2426
}
2527
})
2628
},
2729
teardown: function (callback) {
28-
ipfsd.stop(callback)
30+
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
2931
}
3032
}
3133

test/interface/object.spec.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
'use strict'
44

55
const test = require('interface-ipfs-core')
6+
const parallel = require('async/parallel')
7+
68
const IPFSApi = require('../../src')
79

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

11-
let ipfsd = null
13+
const nodes = []
1214
const common = {
1315
setup: function (callback) {
1416
callback(null, {
@@ -18,14 +20,14 @@ const common = {
1820
return cb(err)
1921
}
2022

21-
ipfsd = _ipfsd
23+
nodes.push(_ipfsd)
2224
cb(null, IPFSApi(_ipfsd.apiAddr))
2325
})
2426
}
2527
})
2628
},
2729
teardown: function (callback) {
28-
ipfsd.stop(callback)
30+
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
2931
}
3032
}
3133

test/interface/pin.spec.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
'use strict'
44

55
const test = require('interface-ipfs-core')
6+
const parallel = require('async/parallel')
7+
68
const IPFSApi = require('../../src')
79

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

11-
let ipfsd = null
13+
const nodes = []
1214
const common = {
1315
setup: function (callback) {
1416
callback(null, {
@@ -18,14 +20,14 @@ const common = {
1820
return cb(err)
1921
}
2022

21-
ipfsd = _ipfsd
23+
nodes.push(_ipfsd)
2224
cb(null, IPFSApi(_ipfsd.apiAddr))
2325
})
2426
}
2527
})
2628
},
2729
teardown: function (callback) {
28-
ipfsd.stop(callback)
30+
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
2931
}
3032
}
3133

test/interface/pubsub.spec.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,33 @@
55
const test = require('interface-ipfs-core')
66
const isNode = require('detect-node')
77

8+
const parallel = require('async/parallel')
9+
810
const IPFSApi = require('../../src')
911

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

1315
if (isNode) {
14-
let ipfsd = null
16+
const nodes = []
1517
const common = {
1618
setup: function (callback) {
1719
callback(null, {
1820
spawnNode: (cb) => {
19-
df.spawn({ args: ['--enable-pubsub-experiment'] }, (err, _ipfsd) => {
20-
if (err) {
21-
return cb(err)
22-
}
23-
24-
ipfsd = _ipfsd
25-
cb(null, IPFSApi(_ipfsd.apiAddr))
26-
})
21+
df.spawn({ args: ['--enable-pubsub-experiment'] },
22+
(err, _ipfsd) => {
23+
if (err) {
24+
return cb(err)
25+
}
26+
27+
nodes.push(_ipfsd)
28+
cb(null, IPFSApi(_ipfsd.apiAddr))
29+
})
2730
}
2831
})
2932
},
3033
teardown: function (callback) {
31-
ipfsd.stop(callback)
34+
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
3235
}
3336
}
3437

test/interface/swarm.spec.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
'use strict'
44

55
const test = require('interface-ipfs-core')
6+
const parallel = require('async/parallel')
7+
68
const IPFSApi = require('../../src')
79

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

11-
let ipfsd = null
13+
const nodes = []
1214
const common = {
1315
setup: function (callback) {
1416
callback(null, {
@@ -28,14 +30,14 @@ const common = {
2830
return cb(err)
2931
}
3032

31-
ipfsd = _ipfsd
33+
nodes.push(_ipfsd)
3234
cb(null, IPFSApi(_ipfsd.apiAddr))
3335
})
3436
}
3537
})
3638
},
3739
teardown: function (callback) {
38-
ipfsd.stop(callback)
40+
parallel(nodes.map((node) => (cb) => node.stop(cb)), callback)
3941
}
4042
}
4143

0 commit comments

Comments
 (0)