@@ -146,8 +146,10 @@ describe('Private network', function () {
146146 jsId2 = ids [ 1 ]
147147 cb ( )
148148 } ) ,
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 ) ,
151153 ( cb ) => parallel ( [
152154 ( cb ) => jsPrivateDaemon . api . swarm . peers ( cb ) ,
153155 ( cb ) => jsSameNetworkDaemon . api . swarm . peers ( cb )
@@ -194,8 +196,10 @@ describe('Private network', function () {
194196 goId = ids [ 1 ]
195197 cb ( )
196198 } ) ,
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 ) ,
199203 ( cb ) => parallel ( [
200204 ( cb ) => goSameNetworkDaemon . api . swarm . peers ( cb ) ,
201205 ( cb ) => jsPrivateDaemon . api . swarm . peers ( cb )
@@ -254,8 +258,10 @@ describe('Private network', function () {
254258 goSameNetId = ids [ 1 ]
255259 cb ( )
256260 } ) ,
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 ) ,
259265 ( cb ) => parallel ( [
260266 ( cb ) => goSameNetworkDaemon . api . swarm . peers ( cb ) ,
261267 ( cb ) => goPrivateDaemon . api . swarm . peers ( cb )
@@ -287,6 +293,7 @@ describe('Private network', function () {
287293
288294 describe ( 'go <-> js on different private networks' , ( ) => {
289295 it ( 'should NOT be able to connect go <-> js' , ( done ) => {
296+ let jsId
290297 let goId
291298
292299 series ( [
@@ -295,21 +302,31 @@ describe('Private network', function () {
295302 ( cb ) => goDiffNetworkDaemon . api . id ( cb )
296303 ] , ( err , ids ) => {
297304 expect ( err ) . to . not . exist ( )
298- goId = ids [ 1 ]
305+ jsId = ids . shift ( )
306+ goId = ids . shift ( )
299307 cb ( )
300308 } ) ,
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+ ] , ( ) => {
306322 done ( )
307323 } )
308324 } )
309325 } )
310326
311327 describe ( 'js <-> js on different private networks' , ( ) => {
312328 it ( 'should NOT be able to connect js <-> js' , ( done ) => {
329+ let jsId
313330 let jsDiffId
314331
315332 series ( [
@@ -318,14 +335,23 @@ describe('Private network', function () {
318335 ( cb ) => jsDiffNetworkDaemon . api . id ( cb )
319336 ] , ( err , ids ) => {
320337 expect ( err ) . to . not . exist ( )
321- jsDiffId = ids [ 1 ]
338+ jsId = ids . shift ( )
339+ jsDiffId = ids . shift ( )
322340 cb ( )
323341 } ) ,
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+ ] , ( ) => {
329355 done ( )
330356 } )
331357 } )
@@ -334,6 +360,7 @@ describe('Private network', function () {
334360 // This will currently timeout, as go will not error
335361 describe . skip ( 'go <-> go on different private networks' , ( ) => {
336362 it ( 'should NOT be able to connect go <-> go' , ( done ) => {
363+ let goId
337364 let goDiffId
338365
339366 series ( [
@@ -342,19 +369,31 @@ describe('Private network', function () {
342369 ( cb ) => goDiffNetworkDaemon . api . id ( cb )
343370 ] , ( err , ids ) => {
344371 expect ( err ) . to . not . exist ( )
345- goDiffId = ids [ 1 ]
372+ goId = ids . shift ( )
373+ goDiffId = ids . shift ( )
346374 cb ( )
347375 } ) ,
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+ ] , ( ) => {
351389 done ( )
352390 } )
353391 } )
354392 } )
355393
356394 describe ( 'js private network <-> go public network' , ( ) => {
357395 it ( 'should NOT be able to connect js <-> go' , ( done ) => {
396+ let jsId
358397 let goPubId
359398
360399 series ( [
@@ -363,21 +402,31 @@ describe('Private network', function () {
363402 ( cb ) => goPublicNetworkDaemon . api . id ( cb )
364403 ] , ( err , ids ) => {
365404 expect ( err ) . to . not . exist ( )
366- goPubId = ids [ 1 ]
405+ jsId = ids . shift ( )
406+ goPubId = ids . shift ( )
367407 cb ( )
368408 } ) ,
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+ ] , ( ) => {
374422 done ( )
375423 } )
376424 } )
377425 } )
378426
379427 describe ( 'js private network <-> js public network' , ( ) => {
380428 it ( 'should NOT be able to connect js <-> js' , ( done ) => {
429+ let jsId
381430 let jsPubId
382431
383432 series ( [
@@ -386,14 +435,23 @@ describe('Private network', function () {
386435 ( cb ) => jsPublicNetworkDaemon . api . id ( cb )
387436 ] , ( err , ids ) => {
388437 expect ( err ) . to . not . exist ( )
389- jsPubId = ids [ 1 ]
438+ jsId = ids . shift ( )
439+ jsPubId = ids . shift ( )
390440 cb ( )
391441 } ) ,
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+ ] , ( ) => {
397455 done ( )
398456 } )
399457 } )
@@ -402,6 +460,7 @@ describe('Private network', function () {
402460 // This will currently timeout, as go will not error
403461 describe . skip ( 'go private network <-> go public network' , ( ) => {
404462 it ( 'should NOT be able to connect go <-> go' , ( done ) => {
463+ let goId
405464 let goPubId
406465
407466 series ( [
@@ -410,12 +469,23 @@ describe('Private network', function () {
410469 ( cb ) => goPublicNetworkDaemon . api . id ( cb )
411470 ] , ( err , ids ) => {
412471 expect ( err ) . to . not . exist ( )
413- goPubId = ids [ 1 ]
472+ goId = ids . shift ( )
473+ goPubId = ids . shift ( )
414474 cb ( )
415475 } ) ,
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+ ] , ( ) => {
419489 done ( )
420490 } )
421491 } )
0 commit comments