@@ -10,14 +10,24 @@ const series = require('async/series')
1010const parallel = require ( 'async/parallel' )
1111const CID = require ( 'cids' )
1212
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+
1424 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 ) => {
1727 if ( err ) {
1828 return cb ( err )
1929 }
20- node . peerId = peerId
30+ node . api . peerId = peerId
2131 cb ( null , node )
2232 } )
2333 ] , callback )
@@ -31,23 +41,26 @@ module.exports = (common) => {
3141 let nodeB
3242 let nodeC
3343
44+ let ipfsdNodes
3445 before ( function ( done ) {
3546 // CI takes longer to instantiate the daemon, so we need to increase the
3647 // timeout for the before step
3748 this . timeout ( 60 * 1000 )
3849
39- common . setup ( ( err , factory ) => {
50+ common . setup ( ( err , df , type ) => {
4051 expect ( err ) . to . not . exist ( )
4152 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 )
4556 ] , ( err , nodes ) => {
4657 expect ( err ) . to . not . exist ( )
4758
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
5164
5265 parallel ( [
5366 ( cb ) => nodeA . swarm . connect ( nodeB . peerId . addresses [ 0 ] , cb ) ,
@@ -58,7 +71,7 @@ module.exports = (common) => {
5871 } )
5972 } )
6073
61- after ( ( done ) => common . teardown ( done ) )
74+ after ( ( done ) => parallel ( ipfsdNodes . map ( ( node ) => ( cb ) => node . stop ( cb ) ) , done ) )
6275
6376 describe ( '.get and .put' , ( ) => {
6477 it ( 'errors when getting a non-existent key from the DHT' , ( done ) => {
0 commit comments