@@ -146,8 +146,10 @@ describe('Private network', function () {
146
146
jsId2 = ids [ 1 ]
147
147
cb ( )
148
148
} ) ,
149
- ( cb ) => jsPrivateDaemon . api . swarm . connect ( jsId2 . addresses [ 0 ] , cb ) ,
150
- ( cb ) => jsSameNetworkDaemon . api . swarm . connect ( jsId . addresses [ 0 ] , cb ) ,
149
+ ( cb ) => parallel ( [
150
+ ( cb ) => jsPrivateDaemon . api . swarm . connect ( jsId2 . addresses [ 0 ] , cb ) ,
151
+ ( cb ) => jsSameNetworkDaemon . api . swarm . connect ( jsId . addresses [ 0 ] , cb )
152
+ ] , cb ) ,
151
153
( cb ) => parallel ( [
152
154
( cb ) => jsPrivateDaemon . api . swarm . peers ( cb ) ,
153
155
( cb ) => jsSameNetworkDaemon . api . swarm . peers ( cb )
@@ -194,8 +196,10 @@ describe('Private network', function () {
194
196
goId = ids [ 1 ]
195
197
cb ( )
196
198
} ) ,
197
- ( cb ) => goSameNetworkDaemon . api . swarm . connect ( jsId . addresses [ 0 ] , cb ) ,
198
- ( cb ) => jsPrivateDaemon . api . swarm . connect ( goId . addresses [ 0 ] , cb ) ,
199
+ ( cb ) => parallel ( [
200
+ ( cb ) => goSameNetworkDaemon . api . swarm . connect ( jsId . addresses [ 0 ] , cb ) ,
201
+ ( cb ) => jsPrivateDaemon . api . swarm . connect ( goId . addresses [ 0 ] , cb )
202
+ ] , cb ) ,
199
203
( cb ) => parallel ( [
200
204
( cb ) => goSameNetworkDaemon . api . swarm . peers ( cb ) ,
201
205
( cb ) => jsPrivateDaemon . api . swarm . peers ( cb )
@@ -254,8 +258,10 @@ describe('Private network', function () {
254
258
goSameNetId = ids [ 1 ]
255
259
cb ( )
256
260
} ) ,
257
- ( cb ) => goSameNetworkDaemon . api . swarm . connect ( goId . addresses [ 0 ] , cb ) ,
258
- ( cb ) => goPrivateDaemon . api . swarm . connect ( goSameNetId . addresses [ 0 ] , cb ) ,
261
+ ( cb ) => parallel ( [
262
+ ( cb ) => goSameNetworkDaemon . api . swarm . connect ( goId . addresses [ 0 ] , cb ) ,
263
+ ( cb ) => goPrivateDaemon . api . swarm . connect ( goSameNetId . addresses [ 0 ] , cb )
264
+ ] , cb ) ,
259
265
( cb ) => parallel ( [
260
266
( cb ) => goSameNetworkDaemon . api . swarm . peers ( cb ) ,
261
267
( cb ) => goPrivateDaemon . api . swarm . peers ( cb )
@@ -287,6 +293,7 @@ describe('Private network', function () {
287
293
288
294
describe ( 'go <-> js on different private networks' , ( ) => {
289
295
it ( 'should NOT be able to connect go <-> js' , ( done ) => {
296
+ let jsId
290
297
let goId
291
298
292
299
series ( [
@@ -295,21 +302,31 @@ describe('Private network', function () {
295
302
( cb ) => goDiffNetworkDaemon . api . id ( cb )
296
303
] , ( err , ids ) => {
297
304
expect ( err ) . to . not . exist ( )
298
- goId = ids [ 1 ]
305
+ jsId = ids . shift ( )
306
+ goId = ids . shift ( )
299
307
cb ( )
300
308
} ) ,
301
- ( cb ) => jsPrivateDaemon . api . swarm . connect ( goId . addresses [ 0 ] , cb )
302
- ] , ( err ) => {
303
- // These errors are currently a bit random depending on who sends data first
304
- // This could be muxing errors, overreading errors, or stream destroyed errors
305
- expect ( err ) . to . exist ( )
309
+ ( cb ) => parallel ( [
310
+ ( cb ) => jsPrivateDaemon . api . swarm . connect ( goId . addresses [ 0 ] , cb ) ,
311
+ ( cb ) => goDiffNetworkDaemon . api . swarm . connect ( jsId . addresses [ 0 ] , cb )
312
+ ] , cb ) ,
313
+ ( cb ) => parallel ( [
314
+ ( cb ) => jsPrivateDaemon . api . swarm . peers ( cb ) ,
315
+ ( cb ) => goDiffNetworkDaemon . api . swarm . peers ( cb )
316
+ ] , ( err , peers ) => {
317
+ expect ( peers [ 0 ] . map ( ( p ) => p . peer . toB58String ( ) ) ) . to . not . include ( goId . id )
318
+ expect ( peers [ 1 ] . map ( ( p ) => p . peer . toB58String ( ) ) ) . to . not . include ( jsId . id )
319
+ cb ( err )
320
+ } )
321
+ ] , ( ) => {
306
322
done ( )
307
323
} )
308
324
} )
309
325
} )
310
326
311
327
describe ( 'js <-> js on different private networks' , ( ) => {
312
328
it ( 'should NOT be able to connect js <-> js' , ( done ) => {
329
+ let jsId
313
330
let jsDiffId
314
331
315
332
series ( [
@@ -318,14 +335,23 @@ describe('Private network', function () {
318
335
( cb ) => jsDiffNetworkDaemon . api . id ( cb )
319
336
] , ( err , ids ) => {
320
337
expect ( err ) . to . not . exist ( )
321
- jsDiffId = ids [ 1 ]
338
+ jsId = ids . shift ( )
339
+ jsDiffId = ids . shift ( )
322
340
cb ( )
323
341
} ) ,
324
- ( cb ) => jsPrivateDaemon . api . swarm . connect ( jsDiffId . addresses [ 0 ] , cb )
325
- ] , ( err ) => {
326
- // These errors are currently a bit random depending on who sends data first
327
- // This could be muxing errors, overreading errors, or stream destroyed errors
328
- expect ( err ) . to . exist ( )
342
+ ( cb ) => parallel ( [
343
+ ( cb ) => jsPrivateDaemon . api . swarm . connect ( jsDiffId . addresses [ 0 ] , cb ) ,
344
+ ( cb ) => jsDiffNetworkDaemon . api . swarm . connect ( jsId . addresses [ 0 ] , cb )
345
+ ] , cb ) ,
346
+ ( cb ) => parallel ( [
347
+ ( cb ) => jsPrivateDaemon . api . swarm . peers ( cb ) ,
348
+ ( cb ) => jsDiffNetworkDaemon . api . swarm . peers ( cb )
349
+ ] , ( err , peers ) => {
350
+ expect ( peers [ 0 ] . map ( ( p ) => p . peer . toB58String ( ) ) ) . to . not . include ( jsDiffId . id )
351
+ expect ( peers [ 1 ] . map ( ( p ) => p . peer . toB58String ( ) ) ) . to . not . include ( jsId . id )
352
+ cb ( err )
353
+ } )
354
+ ] , ( ) => {
329
355
done ( )
330
356
} )
331
357
} )
@@ -334,6 +360,7 @@ describe('Private network', function () {
334
360
// This will currently timeout, as go will not error
335
361
describe . skip ( 'go <-> go on different private networks' , ( ) => {
336
362
it ( 'should NOT be able to connect go <-> go' , ( done ) => {
363
+ let goId
337
364
let goDiffId
338
365
339
366
series ( [
@@ -342,19 +369,31 @@ describe('Private network', function () {
342
369
( cb ) => goDiffNetworkDaemon . api . id ( cb )
343
370
] , ( err , ids ) => {
344
371
expect ( err ) . to . not . exist ( )
345
- goDiffId = ids [ 1 ]
372
+ goId = ids . shift ( )
373
+ goDiffId = ids . shift ( )
346
374
cb ( )
347
375
} ) ,
348
- ( cb ) => goPrivateDaemon . api . swarm . connect ( goDiffId . addresses [ 0 ] , cb )
349
- ] , ( err ) => {
350
- expect ( err ) . to . exist ( )
376
+ ( cb ) => parallel ( [
377
+ ( cb ) => goPrivateDaemon . api . swarm . connect ( goDiffId . addresses [ 0 ] , cb ) ,
378
+ ( cb ) => goDiffNetworkDaemon . api . swarm . connect ( goId . addresses [ 0 ] , cb )
379
+ ] , cb ) ,
380
+ ( cb ) => parallel ( [
381
+ ( cb ) => jsPrivateDaemon . api . swarm . peers ( cb ) ,
382
+ ( cb ) => goDiffNetworkDaemon . api . swarm . peers ( cb )
383
+ ] , ( err , peers ) => {
384
+ expect ( peers [ 0 ] . map ( ( p ) => p . peer . toB58String ( ) ) ) . to . not . include ( goDiffId . id )
385
+ expect ( peers [ 1 ] . map ( ( p ) => p . peer . toB58String ( ) ) ) . to . not . include ( goId . id )
386
+ cb ( err )
387
+ } )
388
+ ] , ( ) => {
351
389
done ( )
352
390
} )
353
391
} )
354
392
} )
355
393
356
394
describe ( 'js private network <-> go public network' , ( ) => {
357
395
it ( 'should NOT be able to connect js <-> go' , ( done ) => {
396
+ let jsId
358
397
let goPubId
359
398
360
399
series ( [
@@ -363,21 +402,31 @@ describe('Private network', function () {
363
402
( cb ) => goPublicNetworkDaemon . api . id ( cb )
364
403
] , ( err , ids ) => {
365
404
expect ( err ) . to . not . exist ( )
366
- goPubId = ids [ 1 ]
405
+ jsId = ids . shift ( )
406
+ goPubId = ids . shift ( )
367
407
cb ( )
368
408
} ) ,
369
- ( cb ) => jsPrivateDaemon . api . swarm . connect ( goPubId . addresses [ 0 ] , cb )
370
- ] , ( err ) => {
371
- // These errors are currently a bit random depending on who sends data first
372
- // This could be muxing errors, bad nonce, or stream destroyed errors
373
- expect ( err ) . to . exist ( )
409
+ ( cb ) => parallel ( [
410
+ ( cb ) => jsPrivateDaemon . api . swarm . connect ( goPubId . addresses [ 0 ] , cb ) ,
411
+ ( cb ) => goPublicNetworkDaemon . api . swarm . connect ( jsId . addresses [ 0 ] , cb )
412
+ ] , cb ) ,
413
+ ( cb ) => parallel ( [
414
+ ( cb ) => jsPrivateDaemon . api . swarm . peers ( cb ) ,
415
+ ( cb ) => goPublicNetworkDaemon . api . swarm . peers ( cb )
416
+ ] , ( err , peers ) => {
417
+ expect ( peers [ 0 ] . map ( ( p ) => p . peer . toB58String ( ) ) ) . to . not . include ( goPubId . id )
418
+ expect ( peers [ 1 ] . map ( ( p ) => p . peer . toB58String ( ) ) ) . to . not . include ( jsId . id )
419
+ cb ( err )
420
+ } )
421
+ ] , ( ) => {
374
422
done ( )
375
423
} )
376
424
} )
377
425
} )
378
426
379
427
describe ( 'js private network <-> js public network' , ( ) => {
380
428
it ( 'should NOT be able to connect js <-> js' , ( done ) => {
429
+ let jsId
381
430
let jsPubId
382
431
383
432
series ( [
@@ -386,14 +435,23 @@ describe('Private network', function () {
386
435
( cb ) => jsPublicNetworkDaemon . api . id ( cb )
387
436
] , ( err , ids ) => {
388
437
expect ( err ) . to . not . exist ( )
389
- jsPubId = ids [ 1 ]
438
+ jsId = ids . shift ( )
439
+ jsPubId = ids . shift ( )
390
440
cb ( )
391
441
} ) ,
392
- ( cb ) => jsPrivateDaemon . api . swarm . connect ( jsPubId . addresses [ 0 ] , cb )
393
- ] , ( err ) => {
394
- // These errors are currently a bit random depending on who sends data first
395
- // This could be muxing errors, bad nonce, or stream destroyed errors
396
- expect ( err ) . to . exist ( )
442
+ ( cb ) => parallel ( [
443
+ ( cb ) => jsPrivateDaemon . api . swarm . connect ( jsPubId . addresses [ 0 ] , cb ) ,
444
+ ( cb ) => jsPublicNetworkDaemon . api . swarm . connect ( jsId . addresses [ 0 ] , cb )
445
+ ] , cb ) ,
446
+ ( cb ) => parallel ( [
447
+ ( cb ) => jsPrivateDaemon . api . swarm . peers ( cb ) ,
448
+ ( cb ) => jsPublicNetworkDaemon . api . swarm . peers ( cb )
449
+ ] , ( err , peers ) => {
450
+ expect ( peers [ 0 ] . map ( ( p ) => p . peer . toB58String ( ) ) ) . to . not . include ( jsPubId . id )
451
+ expect ( peers [ 1 ] . map ( ( p ) => p . peer . toB58String ( ) ) ) . to . not . include ( jsId . id )
452
+ cb ( err )
453
+ } )
454
+ ] , ( ) => {
397
455
done ( )
398
456
} )
399
457
} )
@@ -402,6 +460,7 @@ describe('Private network', function () {
402
460
// This will currently timeout, as go will not error
403
461
describe . skip ( 'go private network <-> go public network' , ( ) => {
404
462
it ( 'should NOT be able to connect go <-> go' , ( done ) => {
463
+ let goId
405
464
let goPubId
406
465
407
466
series ( [
@@ -410,12 +469,23 @@ describe('Private network', function () {
410
469
( cb ) => goPublicNetworkDaemon . api . id ( cb )
411
470
] , ( err , ids ) => {
412
471
expect ( err ) . to . not . exist ( )
413
- goPubId = ids [ 1 ]
472
+ goId = ids . shift ( )
473
+ goPubId = ids . shift ( )
414
474
cb ( )
415
475
} ) ,
416
- ( cb ) => goPrivateDaemon . api . swarm . connect ( goPubId . addresses [ 0 ] , cb )
417
- ] , ( err ) => {
418
- expect ( err ) . to . exist ( )
476
+ ( cb ) => parallel ( [
477
+ ( cb ) => goPrivateDaemon . api . swarm . connect ( goPubId . addresses [ 0 ] , cb ) ,
478
+ ( cb ) => goPublicNetworkDaemon . api . swarm . connect ( goId . addresses [ 0 ] , cb )
479
+ ] , cb ) ,
480
+ ( cb ) => parallel ( [
481
+ ( cb ) => goPrivateDaemon . api . swarm . peers ( cb ) ,
482
+ ( cb ) => goPublicNetworkDaemon . api . swarm . peers ( cb )
483
+ ] , ( err , peers ) => {
484
+ expect ( peers [ 0 ] . map ( ( p ) => p . peer . toB58String ( ) ) ) . to . not . include ( goPubId . id )
485
+ expect ( peers [ 1 ] . map ( ( p ) => p . peer . toB58String ( ) ) ) . to . not . include ( goId . id )
486
+ cb ( err )
487
+ } )
488
+ ] , ( ) => {
419
489
done ( )
420
490
} )
421
491
} )
0 commit comments