@@ -10,14 +10,24 @@ const series = require('async/series')
10
10
const parallel = require ( 'async/parallel' )
11
11
const CID = require ( 'cids' )
12
12
13
- function spawnWithId ( factory , 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
+
14
24
waterfall ( [
15
- ( cb ) => factory . spawnNode ( cb ) ,
16
- ( node , cb ) => node . id ( ( err , peerId ) => {
25
+ ( cb ) => df . spawn ( { type , exec } , cb ) ,
26
+ ( node , cb ) => node . api . id ( ( err , peerId ) => {
17
27
if ( err ) {
18
28
return cb ( err )
19
29
}
20
- node . peerId = peerId
30
+ node . api . peerId = peerId
21
31
cb ( null , node )
22
32
} )
23
33
] , callback )
@@ -31,23 +41,26 @@ module.exports = (common) => {
31
41
let nodeB
32
42
let nodeC
33
43
44
+ let ipfsdNodes
34
45
before ( function ( done ) {
35
46
// CI takes longer to instantiate the daemon, so we need to increase the
36
47
// timeout for the before step
37
48
this . timeout ( 60 * 1000 )
38
49
39
- common . setup ( ( err , factory ) => {
50
+ common . setup ( ( err , df , type ) => {
40
51
expect ( err ) . to . not . exist ( )
41
52
series ( [
42
- ( cb ) => spawnWithId ( factory , cb ) ,
43
- ( cb ) => spawnWithId ( factory , cb ) ,
44
- ( cb ) => spawnWithId ( factory , cb )
53
+ ( cb ) => spawnWithId ( df , type , cb ) ,
54
+ ( cb ) => spawnWithId ( df , type , cb ) ,
55
+ ( cb ) => spawnWithId ( df , type , cb )
45
56
] , ( err , nodes ) => {
46
57
expect ( err ) . to . not . exist ( )
47
58
48
- nodeA = nodes [ 0 ]
49
- nodeB = nodes [ 1 ]
50
- nodeC = nodes [ 2 ]
59
+ ipfsdNodes = nodes
60
+
61
+ nodeA = nodes [ 0 ] . api
62
+ nodeB = nodes [ 1 ] . api
63
+ nodeC = nodes [ 2 ] . api
51
64
52
65
parallel ( [
53
66
( cb ) => nodeA . swarm . connect ( nodeB . peerId . addresses [ 0 ] , cb ) ,
@@ -58,7 +71,7 @@ module.exports = (common) => {
58
71
} )
59
72
} )
60
73
61
- after ( ( done ) => common . teardown ( done ) )
74
+ after ( ( done ) => parallel ( ipfsdNodes . map ( ( node ) => ( cb ) => node . stop ( cb ) ) , done ) )
62
75
63
76
describe ( '.get and .put' , ( ) => {
64
77
it ( 'errors when getting a non-existent key from the DHT' , ( done ) => {
0 commit comments