@@ -63,7 +63,7 @@ function makeCheck (n, done) {
63
63
}
64
64
65
65
module . exports = ( common ) => {
66
- describe ( '.pubsub' , function ( ) {
66
+ describe . only ( '.pubsub' , function ( ) {
67
67
this . timeout ( 80 * 1000 )
68
68
69
69
const getTopic = ( ) => 'pubsub-tests-' + hat ( )
@@ -205,7 +205,7 @@ module.exports = (common) => {
205
205
}
206
206
207
207
ipfs1 . pubsub
208
- . subscribe ( topic , { } , handler )
208
+ . subscribe ( topic , handler , { } )
209
209
. then ( ( ) => ipfs1 . pubsub . publish ( topic , Buffer . from ( 'hi' ) , check ) )
210
210
. catch ( ( err ) => expect ( err ) . to . not . exist ( ) )
211
211
} )
@@ -218,17 +218,17 @@ module.exports = (common) => {
218
218
expect ( msg . data . toString ( ) ) . to . eql ( 'hello' )
219
219
220
220
series ( [
221
- ( cb ) => ipfs1 . pubsub . unsubscribe ( topic , handler1 , cb )
221
+ ( cb ) => ipfs1 . pubsub . unsubscribe ( topic , handler1 , cb ) ,
222
222
( cb ) => ipfs1 . pubsub . ls ( cb ) ,
223
223
( cb ) => ipfs1 . pubsub . unsubscribe ( topic , handler2 , cb ) ,
224
224
( cb ) => ipfs1 . pubsub . ls ( cb )
225
225
] , ( err , res ) => {
226
226
expect ( err ) . to . not . exist ( )
227
227
228
228
// Still subscribed as there is one listener left
229
- expect ( res [ 0 ] ) . to . eql ( [ topic ] )
229
+ expect ( res [ 1 ] ) . to . eql ( [ topic ] )
230
230
// Now all listeners are gone no subscription anymore
231
- expect ( res [ 2 ] ) . to . eql ( [ ] )
231
+ expect ( res [ 3 ] ) . to . eql ( [ ] )
232
232
check ( )
233
233
} )
234
234
}
@@ -310,12 +310,13 @@ module.exports = (common) => {
310
310
311
311
ipfs1 . pubsub . peers ( topic , ( err , peers ) => {
312
312
expect ( err ) . to . not . exist ( )
313
-
314
313
expect ( peers ) . to . be . empty ( )
315
- ipfs1 . pubsub . unsubscribe ( topic , sub1 )
316
- ipfs2 . pubsub . unsubscribe ( topicOther , sub2 )
317
- ipfs3 . pubsub . unsubscribe ( topicOther , sub3 )
318
- done ( )
314
+
315
+ parallel ( [
316
+ ( cb ) => ipfs1 . pubsub . unsubscribe ( topic , sub1 , cb ) ,
317
+ ( cb ) => ipfs2 . pubsub . unsubscribe ( topicOther , sub2 , cb ) ,
318
+ ( cb ) => ipfs3 . pubsub . unsubscribe ( topicOther , sub3 , cb )
319
+ ] , done )
319
320
} )
320
321
} )
321
322
} )
@@ -335,11 +336,12 @@ module.exports = (common) => {
335
336
( cb ) => waitForPeers ( ipfs1 , topic , [ ipfs2 . peerId . id ] , cb )
336
337
] , ( err ) => {
337
338
expect ( err ) . to . not . exist ( )
338
- ipfs1 . pubsub . unsubscribe ( topic , sub1 )
339
- ipfs2 . pubsub . unsubscribe ( topic , sub2 )
340
- ipfs3 . pubsub . unsubscribe ( topic , sub3 )
341
339
342
- done ( )
340
+ parallel ( [
341
+ ( cb ) => ipfs1 . pubsub . unsubscribe ( topic , sub1 , cb ) ,
342
+ ( cb ) => ipfs2 . pubsub . unsubscribe ( topic , sub2 , cb ) ,
343
+ ( cb ) => ipfs3 . pubsub . unsubscribe ( topic , sub3 , cb )
344
+ ] , done )
343
345
} )
344
346
} )
345
347
@@ -359,11 +361,12 @@ module.exports = (common) => {
359
361
] , cb )
360
362
] , ( err ) => {
361
363
expect ( err ) . to . not . exist ( )
362
- ipfs1 . pubsub . unsubscribe ( topic , sub1 )
363
- ipfs2 . pubsub . unsubscribe ( topic , sub2 )
364
- ipfs3 . pubsub . unsubscribe ( topic , sub3 )
365
364
366
- done ( )
365
+ parallel ( [
366
+ ( cb ) => ipfs1 . pubsub . unsubscribe ( topic , sub1 , cb ) ,
367
+ ( cb ) => ipfs2 . pubsub . unsubscribe ( topic , sub2 , cb ) ,
368
+ ( cb ) => ipfs3 . pubsub . unsubscribe ( topic , sub3 , cb )
369
+ ] , done )
367
370
} )
368
371
} )
369
372
} )
@@ -415,11 +418,9 @@ module.exports = (common) => {
415
418
expect ( list . sort ( ) )
416
419
. to . eql ( topics . map ( ( t ) => t . name ) . sort ( ) )
417
420
418
- topics . forEach ( ( t ) => {
419
- ipfs1 . pubsub . unsubscribe ( t . name , t . handler )
420
- } )
421
-
422
- done ( )
421
+ parallel ( topics . map ( ( t ) => {
422
+ return ( cb ) => ipfs1 . pubsub . unsubscribe ( t . name , t . handler , cb )
423
+ } ) , done )
423
424
} )
424
425
} )
425
426
} )
@@ -436,8 +437,8 @@ module.exports = (common) => {
436
437
437
438
afterEach ( ( done ) => {
438
439
parallel ( [
439
- ( cb ) => ipfs1 . pubsub . unsubscribe ( topic , sub1 , cb )
440
- ( cb ) = > ipfs2 . pubsub . unsubscribe ( topic , sub2 , cb )
440
+ ( cb ) => ipfs1 . pubsub . unsubscribe ( topic , sub1 , cb ) ,
441
+ ( cb ) => ipfs2 . pubsub . unsubscribe ( topic , sub2 , cb )
441
442
] , done )
442
443
} )
443
444
@@ -589,9 +590,11 @@ module.exports = (common) => {
589
590
topic = getTopic ( )
590
591
} )
591
592
592
- afterEach ( ( ) => {
593
- ipfs1 . pubsub . unsubscribe ( topic , sub1 )
594
- ipfs2 . pubsub . unsubscribe ( topic , sub2 )
593
+ afterEach ( ( done ) => {
594
+ parallel ( [
595
+ ( cb ) => ipfs1 . pubsub . unsubscribe ( topic , sub1 , cb ) ,
596
+ ( cb ) => ipfs2 . pubsub . unsubscribe ( topic , sub2 , cb )
597
+ ] , done )
595
598
} )
596
599
597
600
it ( 'send/receive 10k messages' , function ( done ) {
@@ -672,16 +675,16 @@ module.exports = (common) => {
672
675
expect ( err ) . to . not . exist ( )
673
676
each (
674
677
handlers ,
675
- ( handler , cb ) => ipfs1 . pubsub . unsubscribe ( someTopic , handler , cb )
678
+ ( handler , cb ) => ipfs1 . pubsub . unsubscribe ( someTopic , handler , cb ) ,
676
679
( err ) => {
677
680
expect ( err ) . to . not . exist ( )
678
681
ipfs1 . pubsub . ls ( ( err , topics ) => {
679
682
expect ( err ) . to . not . exist ( )
680
683
expect ( topics ) . to . eql ( [ ] )
681
684
done ( )
682
685
} )
683
- } )
684
- } )
686
+ }
687
+ )
685
688
}
686
689
)
687
690
} )
0 commit comments