@@ -104,14 +104,13 @@ describe('daemon', () => {
104
104
}
105
105
} )
106
106
107
- try {
108
- await daemon
109
- throw new Error ( 'Did not kill process' )
110
- } catch ( err ) {
111
- expect ( err . killed ) . to . be . true ( )
112
-
113
- expect ( stdout ) . to . include ( 'Daemon is ready' )
114
- }
107
+ await daemon . then (
108
+ ( ) => expect . fail ( 'Did not kill process' ) ,
109
+ ( err ) => {
110
+ expect ( err . killed ) . to . be . true ( )
111
+ expect ( stdout ) . to . include ( 'Daemon is ready' )
112
+ }
113
+ )
115
114
} )
116
115
117
116
it ( 'should allow bind to multiple addresses for API and Gateway' , async function ( ) {
@@ -142,15 +141,15 @@ describe('daemon', () => {
142
141
}
143
142
} )
144
143
145
- try {
146
- await daemon
147
- throw new Error ( 'Did not kill process' )
148
- } catch ( err ) {
149
- expect ( err . killed ) . to . be . true ( )
144
+ await daemon . then (
145
+ ( ) => expect . fail ( 'Did not kill process' ) ,
146
+ ( err ) => {
147
+ expect ( err . killed ) . to . be . true ( )
150
148
151
- apiAddrs . forEach ( addr => expect ( err . stdout ) . to . include ( `API listening on ${ addr . slice ( 0 , - 2 ) } ` ) )
152
- gatewayAddrs . forEach ( addr => expect ( err . stdout ) . to . include ( `Gateway (read only) listening on ${ addr . slice ( 0 , - 2 ) } ` ) )
153
- }
149
+ apiAddrs . forEach ( addr => expect ( err . stdout ) . to . include ( `API listening on ${ addr . slice ( 0 , - 2 ) } ` ) )
150
+ gatewayAddrs . forEach ( addr => expect ( err . stdout ) . to . include ( `Gateway (read only) listening on ${ addr . slice ( 0 , - 2 ) } ` ) )
151
+ }
152
+ )
154
153
} )
155
154
156
155
it ( 'should allow no bind addresses for API and Gateway' , async function ( ) {
@@ -171,15 +170,15 @@ describe('daemon', () => {
171
170
}
172
171
} )
173
172
174
- try {
175
- await daemon
176
- throw new Error ( 'Did not kill process' )
177
- } catch ( err ) {
178
- expect ( err . killed ) . to . be . true ( )
173
+ await daemon . then (
174
+ ( ) => expect . fail ( 'Did not kill process' ) ,
175
+ ( err ) => {
176
+ expect ( err . killed ) . to . be . true ( )
179
177
180
- expect ( err . stdout ) . to . not . include ( 'API listening on' )
181
- expect ( err . stdout ) . to . not . include ( 'Gateway (read only) listening on' )
182
- }
178
+ expect ( err . stdout ) . to . not . include ( 'API listening on' )
179
+ expect ( err . stdout ) . to . not . include ( 'Gateway (read only) listening on' )
180
+ }
181
+ )
183
182
} )
184
183
185
184
skipOnWindows ( 'should handle SIGINT gracefully' , async function ( ) {
@@ -211,32 +210,14 @@ describe('daemon', () => {
211
210
await ipfs ( 'init' )
212
211
213
212
const daemon = ipfs ( 'daemon --silent' )
214
- const stop = async ( err ) => {
215
- daemon . kill ( )
216
-
217
- if ( err ) {
218
- throw err
219
- }
220
213
221
- try {
222
- await daemon
223
- } catch ( err ) {
224
- if ( ! err . killed ) {
225
- throw err
226
- }
227
- }
228
- }
214
+ setTimeout ( ( ) => {
215
+ daemon . kill ( )
216
+ } , 5 * 1000 )
229
217
230
- return new Promise ( ( resolve , reject ) => {
231
- daemon . stdout . on ( 'data' , ( data ) => {
232
- reject ( new Error ( 'Output was received ' + data . toString ( 'utf8' ) ) )
233
- } )
218
+ const output = await daemon
234
219
235
- setTimeout ( ( ) => {
236
- resolve ( )
237
- } , 5 * 1000 )
238
- } )
239
- . then ( stop , stop )
220
+ expect ( output ) . to . be . empty ( )
240
221
} )
241
222
242
223
it ( 'should present ipfs path help when option help is received' , async function ( ) {
@@ -262,16 +243,16 @@ describe('daemon', () => {
262
243
}
263
244
} )
264
245
265
- try {
266
- await daemon
267
- throw new Error ( 'Did not kill process' )
268
- } catch ( err ) {
269
- expect ( err . killed ) . to . be . true ( )
246
+ await daemon . then (
247
+ ( ) => expect . fail ( 'Did not kill process' ) ,
248
+ ( err ) => {
249
+ expect ( err . killed ) . to . be . true ( )
270
250
271
- expect ( err . stdout ) . to . include ( `js-ipfs version: ${ pkg . version } ` )
272
- expect ( err . stdout ) . to . include ( `System version: ${ os . arch ( ) } /${ os . platform ( ) } ` )
273
- expect ( err . stdout ) . to . include ( `Node.js version: ${ process . versions . node } ` )
274
- }
251
+ expect ( err . stdout ) . to . include ( `js-ipfs version: ${ pkg . version } ` )
252
+ expect ( err . stdout ) . to . include ( `System version: ${ os . arch ( ) } /${ os . platform ( ) } ` )
253
+ expect ( err . stdout ) . to . include ( `Node.js version: ${ process . versions . node } ` )
254
+ }
255
+ )
275
256
} )
276
257
277
258
it ( 'should init by default' , async function ( ) {
@@ -290,12 +271,10 @@ describe('daemon', () => {
290
271
}
291
272
} )
292
273
293
- try {
294
- await daemon
295
- throw new Error ( 'Did not kill process' )
296
- } catch ( err ) {
297
- expect ( err . killed ) . to . be . true ( )
298
- }
274
+ await daemon . then (
275
+ ( ) => expect . fail ( 'Did not kill process' ) ,
276
+ ( err ) => expect ( err . killed ) . to . be . true ( )
277
+ )
299
278
300
279
expect ( fs . existsSync ( repoPath ) ) . to . be . true ( )
301
280
} )
0 commit comments