@@ -17,9 +17,7 @@ const multihashing = require('multihashing-async')
17
17
const CID = require ( 'cids' )
18
18
19
19
const DaemonFactory = require ( 'ipfsd-ctl' )
20
- const df = DaemonFactory . create ( { type : 'js' } )
21
-
22
- const dfProc = DaemonFactory . create ( { type : 'proc' } )
20
+ const df = DaemonFactory . create ( )
23
21
24
22
// This gets replaced by '../utils/create-repo-browser.js' in the browser
25
23
const createTempRepo = require ( '../utils/create-repo-nodejs.js' )
@@ -69,14 +67,7 @@ function connectNodes (remoteNode, inProcNode, callback) {
69
67
let nodes = [ ]
70
68
71
69
function addNode ( inProcNode , callback ) {
72
- df . spawn ( {
73
- exec : `./src/cli/bin.js` ,
74
- config : {
75
- Addresses : {
76
- Swarm : [ `/ip4/127.0.0.1/tcp/0/ws` ]
77
- }
78
- }
79
- } , ( err , ipfsd ) => {
70
+ df . spawn ( { type : 'js' , exec : `./src/cli/bin.js` } , ( err , ipfsd ) => {
80
71
expect ( err ) . to . not . exist ( )
81
72
nodes . push ( ipfsd )
82
73
connectNodes ( ipfsd . api , inProcNode , ( err ) => callback ( err , ipfsd . api ) )
@@ -91,7 +82,8 @@ describe('bitswap', function () {
91
82
beforeEach ( function ( done ) {
92
83
this . timeout ( 60 * 1000 )
93
84
94
- let config = {
85
+ let options = {
86
+ repo : createTempRepo ( ) ,
95
87
config : {
96
88
Addresses : {
97
89
Swarm : [ ]
@@ -106,7 +98,7 @@ describe('bitswap', function () {
106
98
}
107
99
108
100
if ( isNode ) {
109
- config = Object . assign ( config , {
101
+ options = Object . assign ( options , {
110
102
config : {
111
103
Addresses : {
112
104
Swarm : [ '/ip4/127.0.0.1/tcp/0' ]
@@ -115,21 +107,18 @@ describe('bitswap', function () {
115
107
} )
116
108
}
117
109
118
- dfProc . spawn ( { exec : IPFS , config } , ( err , _ipfsd ) => {
119
- expect ( err ) . to . not . exist ( )
120
- nodes . push ( _ipfsd )
121
- inProcNode = _ipfsd . api
122
- done ( )
123
- } )
110
+ inProcNode = new IPFS ( options )
111
+ inProcNode . on ( 'ready' , ( ) => done ( ) )
124
112
} )
125
113
126
114
afterEach ( function ( done ) {
127
115
this . timeout ( 80 * 1000 )
128
116
const tasks = nodes . map ( ( node ) => ( cb ) => node . stop ( cb ) )
117
+ tasks . push ( ( cb ) => setTimeout ( ( ) => inProcNode . stop ( ( ) => cb ( ) ) , 500 ) )
129
118
parallel ( tasks , ( err ) => {
130
119
expect ( err ) . to . not . exist ( )
131
120
nodes = [ ]
132
- done ( )
121
+ done ( err )
133
122
} )
134
123
} )
135
124
0 commit comments