@@ -61,21 +61,14 @@ describe('high level API - with everything mixed all together!', function () {
6161 peerC . multiaddr . add ( multiaddr ( '/ip4/127.0.0.1/tcp/0' ) )
6262
6363 swarmA . transport . add ( 'tcp' , new TCP ( ) )
64- swarmA . transport . listen ( 'tcp' , { } , null , ready )
65-
6664 swarmB . transport . add ( 'tcp' , new TCP ( ) )
67- swarmB . transport . listen ( 'tcp' , { } , null , ready )
68-
6965 swarmC . transport . add ( 'tcp' , new TCP ( ) )
70- swarmC . transport . listen ( 'tcp' , { } , null , ready )
7166
72- var counter = 0
73-
74- function ready ( ) {
75- if ( ++ counter === 3 ) {
76- done ( )
77- }
78- }
67+ parallel ( [
68+ ( cb ) => swarmA . transport . listen ( 'tcp' , { } , null , cb ) ,
69+ ( cb ) => swarmB . transport . listen ( 'tcp' , { } , null , cb ) ,
70+ ( cb ) => swarmC . transport . listen ( 'tcp' , { } , null , cb )
71+ ] , done )
7972 } )
8073
8174 it . skip ( 'add utp' , ( done ) => { } )
@@ -87,27 +80,19 @@ describe('high level API - with everything mixed all together!', function () {
8780 peerE . multiaddr . add ( multiaddr ( '/ip4/127.0.0.1/tcp/9042/websockets' ) )
8881
8982 swarmB . transport . add ( 'ws' , new WebSockets ( ) )
90- swarmB . transport . listen ( 'ws' , { } , null , ready )
91-
9283 swarmC . transport . add ( 'ws' , new WebSockets ( ) )
93- swarmC . transport . listen ( 'ws' , { } , null , ready )
94-
9584 swarmD . transport . add ( 'ws' , new WebSockets ( ) )
96- swarmD . transport . listen ( 'ws' , { } , null , ready )
97-
9885 swarmE . transport . add ( 'ws' , new WebSockets ( ) )
99- swarmE . transport . listen ( 'ws' , { } , null , ready )
10086
101- var counter = 0
102-
103- function ready ( ) {
104- if ( ++ counter === 4 ) {
105- done ( )
106- }
107- }
87+ parallel ( [
88+ ( cb ) => swarmB . transport . listen ( 'ws' , { } , null , cb ) ,
89+ ( cb ) => swarmC . transport . listen ( 'ws' , { } , null , cb ) ,
90+ ( cb ) => swarmD . transport . listen ( 'ws' , { } , null , cb ) ,
91+ ( cb ) => swarmE . transport . listen ( 'ws' , { } , null , cb )
92+ ] , done )
10893 } )
10994
110- it ( 'add spdy' , ( done ) => {
95+ it ( 'add spdy' , ( ) => {
11196 swarmA . connection . addStreamMuxer ( spdy )
11297 swarmB . connection . addStreamMuxer ( spdy )
11398 swarmC . connection . addStreamMuxer ( spdy )
@@ -119,26 +104,26 @@ describe('high level API - with everything mixed all together!', function () {
119104 swarmC . connection . reuse ( )
120105 swarmD . connection . reuse ( )
121106 swarmE . connection . reuse ( )
122-
123- done ( )
124107 } )
125108
126- it . skip ( 'add multiplex' , ( done ) => { } )
109+ it . skip ( 'add multiplex' , ( ) => { } )
127110
128111 it ( 'warm up from A to B on tcp to tcp+ws' , ( done ) => {
129- swarmB . once ( 'peer-mux-established' , ( peerInfo ) => {
130- expect ( peerInfo . id . toB58String ( ) ) . to . equal ( peerA . id . toB58String ( ) )
131- } )
132-
133- swarmA . once ( 'peer-mux-established' , ( peerInfo ) => {
134- expect ( peerInfo . id . toB58String ( ) ) . to . equal ( peerB . id . toB58String ( ) )
135- } )
136-
137- swarmA . dial ( peerB , ( err ) => {
138- expect ( err ) . to . not . exist
139- expect ( Object . keys ( swarmA . muxedConns ) . length ) . to . equal ( 1 )
140- done ( )
141- } )
112+ parallel ( [
113+ ( cb ) => swarmB . once ( 'peer-mux-established' , ( peerInfo ) => {
114+ expect ( peerInfo . id . toB58String ( ) ) . to . equal ( peerA . id . toB58String ( ) )
115+ cb ( )
116+ } ) ,
117+ ( cb ) => swarmA . once ( 'peer-mux-established' , ( peerInfo ) => {
118+ expect ( peerInfo . id . toB58String ( ) ) . to . equal ( peerB . id . toB58String ( ) )
119+ cb ( )
120+ } ) ,
121+ ( cb ) => swarmA . dial ( peerB , ( err ) => {
122+ expect ( err ) . to . not . exist
123+ expect ( Object . keys ( swarmA . muxedConns ) . length ) . to . equal ( 1 )
124+ cb ( )
125+ } )
126+ ] , done )
142127 } )
143128
144129 it ( 'warm up a warmed up, from B to A' , ( done ) => {
@@ -225,11 +210,9 @@ describe('high level API - with everything mixed all together!', function () {
225210 } )
226211
227212 it ( 'close a muxer emits event' , ( done ) => {
228- swarmC . close ( ( err ) => {
229- if ( err ) throw err
230- } )
231- swarmA . once ( 'peer-mux-closed' , ( peerInfo ) => {
232- done ( )
233- } )
213+ parallel ( [
214+ ( cb ) => swarmC . close ( cb ) ,
215+ ( cb ) => swarmA . once ( 'peer-mux-closed' , ( ) => cb ( ) )
216+ ] , done )
234217 } )
235218} )
0 commit comments