@@ -17,14 +17,17 @@ const multihashing = require('multihashing-async')
1717const CID = require ( 'cids' )
1818
1919const IPFSFactory = require ( 'ipfsd-ctl' )
20- const fDaemon = IPFSFactory . create ( { type : 'js' } )
21- const fInProc = IPFSFactory . create ( { type : 'proc' } )
2220
2321// This gets replaced by '../utils/create-repo-browser.js' in the browser
2422const createTempRepo = require ( '../utils/create-repo-nodejs.js' )
2523
2624const IPFS = require ( '../../src/core' )
2725
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+
2831function makeBlock ( callback ) {
2932 const d = Buffer . from ( `IPFS is awesome ${ Math . random ( ) } ` )
3033
@@ -67,7 +70,7 @@ function connectNodes (remoteNode, inProcNode, callback) {
6770
6871let nodes = [ ]
6972
70- function addNode ( inProcNode , callback ) {
73+ function addNode ( fDaemon , inProcNode , callback ) {
7174 fDaemon . spawn ( {
7275 exec : './src/cli/bin.js' ,
7376 initOptions : { bits : 512 } ,
@@ -89,10 +92,17 @@ function addNode (inProcNode, callback) {
8992 } )
9093}
9194
92- describe ( 'bitswap' , function ( ) {
95+ skipOnWindows ( 'bitswap' , function ( ) {
9396 this . timeout ( 80 * 1000 )
9497
9598 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+ } )
96106
97107 beforeEach ( function ( done ) {
98108 this . timeout ( 60 * 1000 )
@@ -150,7 +160,7 @@ describe('bitswap', function () {
150160 waterfall ( [
151161 ( cb ) => parallel ( [
152162 ( cb ) => makeBlock ( cb ) ,
153- ( cb ) => addNode ( inProcNode , cb )
163+ ( cb ) => addNode ( fDaemon , inProcNode , cb )
154164 ] , cb ) ,
155165 ( res , cb ) => {
156166 block = res [ 0 ]
@@ -178,11 +188,11 @@ describe('bitswap', function () {
178188 blocks = _blocks
179189 cb ( )
180190 } ) ,
181- ( cb ) => addNode ( inProcNode , ( err , _ipfs ) => {
191+ ( cb ) => addNode ( fDaemon , inProcNode , ( err , _ipfs ) => {
182192 remoteNodes . push ( _ipfs )
183193 cb ( err )
184194 } ) ,
185- ( cb ) => addNode ( inProcNode , ( err , _ipfs ) => {
195+ ( cb ) => addNode ( fDaemon , inProcNode , ( err , _ipfs ) => {
186196 remoteNodes . push ( _ipfs )
187197 cb ( err )
188198 } ) ,
@@ -213,14 +223,17 @@ describe('bitswap', function () {
213223 } )
214224 } )
215225
216- describe ( 'transfer a file between' , ( ) => {
226+ describe ( 'transfer a file between' , function ( ) {
227+ this . timeout ( 160 * 1000 )
228+
217229 it ( '2 peers' , ( done ) => {
218230 // TODO make this test more interesting (10Mb file)
231+ // TODO remove randomness from the test
219232 const file = Buffer . from ( `I love IPFS <3 ${ Math . random ( ) } ` )
220233
221234 waterfall ( [
222235 // 0. Start node
223- ( cb ) => addNode ( inProcNode , cb ) ,
236+ ( cb ) => addNode ( fDaemon , inProcNode , cb ) ,
224237 // 1. Add file to tmp instance
225238 ( remote , cb ) => {
226239 remote . files . add ( [ { path : 'awesome.txt' , content : file } ] , cb )
0 commit comments