@@ -61,21 +61,14 @@ describe('high level API - with everything mixed all together!', function () {
61
61
peerC . multiaddr . add ( multiaddr ( '/ip4/127.0.0.1/tcp/0' ) )
62
62
63
63
swarmA . transport . add ( 'tcp' , new TCP ( ) )
64
- swarmA . transport . listen ( 'tcp' , { } , null , ready )
65
-
66
64
swarmB . transport . add ( 'tcp' , new TCP ( ) )
67
- swarmB . transport . listen ( 'tcp' , { } , null , ready )
68
-
69
65
swarmC . transport . add ( 'tcp' , new TCP ( ) )
70
- swarmC . transport . listen ( 'tcp' , { } , null , ready )
71
66
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 )
79
72
} )
80
73
81
74
it . skip ( 'add utp' , ( done ) => { } )
@@ -87,27 +80,19 @@ describe('high level API - with everything mixed all together!', function () {
87
80
peerE . multiaddr . add ( multiaddr ( '/ip4/127.0.0.1/tcp/9042/websockets' ) )
88
81
89
82
swarmB . transport . add ( 'ws' , new WebSockets ( ) )
90
- swarmB . transport . listen ( 'ws' , { } , null , ready )
91
-
92
83
swarmC . transport . add ( 'ws' , new WebSockets ( ) )
93
- swarmC . transport . listen ( 'ws' , { } , null , ready )
94
-
95
84
swarmD . transport . add ( 'ws' , new WebSockets ( ) )
96
- swarmD . transport . listen ( 'ws' , { } , null , ready )
97
-
98
85
swarmE . transport . add ( 'ws' , new WebSockets ( ) )
99
- swarmE . transport . listen ( 'ws' , { } , null , ready )
100
86
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 )
108
93
} )
109
94
110
- it ( 'add spdy' , ( done ) => {
95
+ it ( 'add spdy' , ( ) => {
111
96
swarmA . connection . addStreamMuxer ( spdy )
112
97
swarmB . connection . addStreamMuxer ( spdy )
113
98
swarmC . connection . addStreamMuxer ( spdy )
@@ -119,26 +104,26 @@ describe('high level API - with everything mixed all together!', function () {
119
104
swarmC . connection . reuse ( )
120
105
swarmD . connection . reuse ( )
121
106
swarmE . connection . reuse ( )
122
-
123
- done ( )
124
107
} )
125
108
126
- it . skip ( 'add multiplex' , ( done ) => { } )
109
+ it . skip ( 'add multiplex' , ( ) => { } )
127
110
128
111
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 )
142
127
} )
143
128
144
129
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 () {
225
210
} )
226
211
227
212
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 )
234
217
} )
235
218
} )
0 commit comments