@@ -11,10 +11,39 @@ const path = require('path')
11
11
// this comment is used by mocha, do not delete
12
12
/*global describe, before, it*/
13
13
14
+ describe ( 'ipfs executable path' , function ( ) {
15
+ this . timeout ( 2000 )
16
+ let Node
17
+
18
+ it ( 'has the correct path when used via Electron' , ( ) => {
19
+ process . versions [ 'electron' ] = '0.0.0-test' // Electron sets its version to the array --> we know that we're using Electron
20
+ process . resourcesPath = '/test/path/one/more' // Path to the Electron app, set by Electron
21
+
22
+ // Force reload of the module (pathing is handled globally in ../lib/node.js)
23
+ delete require . cache [ require . resolve ( '../lib/node.js' ) ]
24
+ Node = require ( '../lib/node.js' )
25
+
26
+ var node = new Node ( )
27
+ assert . equal ( node . exec , path . join ( process . resourcesPath , '/app' , 'node_modules/go-ipfs-dep/go-ipfs/ipfs' ) )
28
+ } )
29
+
30
+ it ( 'has the correct path when used via Node.js' , ( ) => {
31
+ delete process . versions [ 'electron' ]
32
+ delete process . resourcesPath
33
+
34
+ // Force reload of the module (pathing is handled globally in ../lib/node.js)
35
+ delete require . cache [ require . resolve ( '../lib/node.js' ) ]
36
+ Node = require ( '../lib/node.js' )
37
+
38
+ var node = new Node ( )
39
+ assert . equal ( node . exec , path . join ( process . cwd ( ) , 'node_modules/go-ipfs-dep/go-ipfs/ipfs' ) )
40
+ } )
41
+ } )
42
+
14
43
describe ( 'disposable node with local api' , function ( ) {
15
44
this . timeout ( 20000 )
16
45
let ipfs
17
- before ( done => {
46
+ before ( ( done ) => {
18
47
ipfsd . disposable ( ( err , node ) => {
19
48
if ( err ) throw err
20
49
node . startDaemon ( ( err , ignore ) => {
@@ -32,7 +61,7 @@ describe('disposable node with local api', function () {
32
61
33
62
let store , retrieve
34
63
35
- before ( done => {
64
+ before ( ( done ) => {
36
65
const blorb = Buffer ( 'blorb' )
37
66
ipfs . block . put ( blorb , ( err , res ) => {
38
67
if ( err ) throw err
@@ -42,7 +71,9 @@ describe('disposable node with local api', function () {
42
71
if ( err ) throw err
43
72
let buf = ''
44
73
res
45
- . on ( 'data' , data => buf += data )
74
+ . on ( 'data' , ( data ) => {
75
+ buf += data
76
+ } )
46
77
. on ( 'end' , ( ) => {
47
78
retrieve = buf
48
79
done ( )
@@ -61,7 +92,7 @@ describe('disposable node with local api', function () {
61
92
describe ( 'disposableApi node' , function ( ) {
62
93
this . timeout ( 20000 )
63
94
let ipfs
64
- before ( done => {
95
+ before ( ( done ) => {
65
96
ipfsd . disposableApi ( ( err , api ) => {
66
97
if ( err ) throw err
67
98
ipfs = api
@@ -78,7 +109,7 @@ describe('disposableApi node', function () {
78
109
79
110
let store , retrieve
80
111
81
- before ( done => {
112
+ before ( ( done ) => {
82
113
const blorb = Buffer ( 'blorb' )
83
114
ipfs . block . put ( blorb , ( err , res ) => {
84
115
if ( err ) throw err
@@ -88,7 +119,9 @@ describe('disposableApi node', function () {
88
119
if ( err ) throw err
89
120
let buf = ''
90
121
res
91
- . on ( 'data' , data => buf += data )
122
+ . on ( 'data' , ( data ) => {
123
+ buf += data
124
+ } )
92
125
. on ( 'end' , ( ) => {
93
126
retrieve = buf
94
127
done ( )
@@ -109,7 +142,7 @@ describe('starting and stopping', function () {
109
142
let node
110
143
111
144
describe ( 'init' , ( ) => {
112
- before ( done => {
145
+ before ( ( done ) => {
113
146
ipfsd . disposable ( ( err , res ) => {
114
147
if ( err ) throw err
115
148
node = res
@@ -130,7 +163,7 @@ describe('starting and stopping', function () {
130
163
131
164
describe ( 'starting' , ( ) => {
132
165
let ipfs
133
- before ( done => {
166
+ before ( ( done ) => {
134
167
node . startDaemon ( ( err , res ) => {
135
168
if ( err ) throw err
136
169
@@ -139,7 +172,7 @@ describe('starting and stopping', function () {
139
172
140
173
// actually running?
141
174
run ( 'kill' , [ '-0' , pid ] )
142
- . on ( err , err => { throw err } )
175
+ . on ( err , ( err ) => { throw err } )
143
176
. on ( 'end' , ( ) => { done ( ) } )
144
177
} )
145
178
} )
@@ -151,8 +184,8 @@ describe('starting and stopping', function () {
151
184
152
185
let stopped = false
153
186
describe ( 'stopping' , ( ) => {
154
- before ( done => {
155
- node . stopDaemon ( err => {
187
+ before ( ( done ) => {
188
+ node . stopDaemon ( ( err ) => {
156
189
if ( err ) throw err
157
190
stopped = true
158
191
} )
@@ -178,7 +211,7 @@ describe('setting up and initializing a local node', () => {
178
211
const testpath1 = '/tmp/ipfstestpath1'
179
212
180
213
describe ( 'cleanup' , ( ) => {
181
- before ( done => {
214
+ before ( ( done ) => {
182
215
rimraf ( testpath1 , done )
183
216
} )
184
217
@@ -189,7 +222,7 @@ describe('setting up and initializing a local node', () => {
189
222
190
223
describe ( 'setup' , ( ) => {
191
224
let node
192
- before ( done => {
225
+ before ( ( done ) => {
193
226
ipfsd . local ( testpath1 , ( err , res ) => {
194
227
if ( err ) throw err
195
228
node = res
@@ -208,8 +241,8 @@ describe('setting up and initializing a local node', () => {
208
241
describe ( 'initialize' , function ( ) {
209
242
this . timeout ( 10000 )
210
243
211
- before ( done => {
212
- node . init ( err => {
244
+ before ( ( done ) => {
245
+ node . init ( ( err ) => {
213
246
if ( err ) throw err
214
247
done ( )
215
248
} )
@@ -235,7 +268,7 @@ describe('change config values of a disposable node', function () {
235
268
236
269
let ipfsNode
237
270
238
- before ( done => {
271
+ before ( ( done ) => {
239
272
ipfsd . disposable ( ( err , node ) => {
240
273
if ( err ) {
241
274
throw err
@@ -245,7 +278,7 @@ describe('change config values of a disposable node', function () {
245
278
} )
246
279
} )
247
280
248
- it ( 'Should return a config value' , done => {
281
+ it ( 'Should return a config value' , ( done ) => {
249
282
ipfsNode . getConfig ( 'Bootstrap' , ( err , config ) => {
250
283
if ( err ) {
251
284
throw err
@@ -255,8 +288,8 @@ describe('change config values of a disposable node', function () {
255
288
} )
256
289
} )
257
290
258
- it ( 'Should set a config value' , done => {
259
- ipfsNode . setConfig ( 'Bootstrap' , null , err => {
291
+ it ( 'Should set a config value' , ( done ) => {
292
+ ipfsNode . setConfig ( 'Bootstrap' , null , ( err ) => {
260
293
if ( err ) {
261
294
throw err
262
295
}
@@ -273,7 +306,7 @@ describe('change config values of a disposable node', function () {
273
306
} )
274
307
275
308
describe ( 'external ipfs binaray' , ( ) => {
276
- it ( 'allows passing via $IPFS_EXEC' , done => {
309
+ it ( 'allows passing via $IPFS_EXEC' , ( done ) => {
277
310
process . env . IPFS_EXEC = '/some/path'
278
311
ipfsd . local ( ( err , node ) => {
279
312
if ( err ) throw err
@@ -287,7 +320,7 @@ describe('external ipfs binaray', () => {
287
320
} )
288
321
289
322
describe ( 'version' , ( ) => {
290
- it ( 'prints the version' , done => {
323
+ it ( 'prints the version' , ( done ) => {
291
324
ipfsd . version ( ( err , version ) => {
292
325
if ( err ) throw err
293
326
@@ -302,7 +335,7 @@ describe('ipfs-api version', function () {
302
335
303
336
let ipfs
304
337
305
- before ( done => {
338
+ before ( ( done ) => {
306
339
ipfsd . disposable ( ( err , node ) => {
307
340
if ( err ) throw err
308
341
node . startDaemon ( ( err , ignore ) => {
@@ -313,13 +346,14 @@ describe('ipfs-api version', function () {
313
346
} )
314
347
} )
315
348
316
- it ( 'uses the correct ipfs-api' , done => {
349
+ // NOTE: if you change ../lib/node.js, the hash will need to be changed
350
+ it ( 'uses the correct ipfs-api' , ( done ) => {
317
351
ipfs . add ( path . join ( __dirname , '../lib' ) , { recursive : true } , ( err , res ) => {
318
352
if ( err ) throw err
319
353
320
354
const added = res [ res . length - 1 ]
321
355
assert ( added )
322
- assert . equal ( added . Hash , 'QmWab9Js2ueyo739mUdLxv45u6YkEgd3LmzXKn4SQjcFuq ' )
356
+ assert . equal ( added . Hash , 'QmTioWzyNf4ybt6RDYCxqWBGYBfDqFWCoNwRKF89xgUvgF ' )
323
357
done ( )
324
358
} )
325
359
} )
0 commit comments