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