@@ -232,6 +232,19 @@ describe('transport - websockets', function () {
232
232
conn . end ( )
233
233
} )
234
234
235
+ it ( 'dial (conn from callback)' , ( done ) => {
236
+ swarmA . transport . dial ( 'ws' , multiaddr ( '/ip4/127.0.0.1/tcp/9999/websockets' ) , ( err , conn ) => {
237
+ expect ( err ) . to . not . exist
238
+
239
+ conn . pipe ( bl ( ( err , data ) => {
240
+ expect ( err ) . to . not . exist
241
+ done ( )
242
+ } ) )
243
+ conn . write ( 'hey' )
244
+ conn . end ( )
245
+ } )
246
+ } )
247
+
235
248
it ( 'close' , ( done ) => {
236
249
var count = 0
237
250
swarmA . transport . close ( 'ws' , closed )
@@ -323,6 +336,19 @@ describe('high level API - 1st without stream multiplexing (on TCP)', function (
323
336
} )
324
337
} )
325
338
339
+ it ( 'dial on protocol (returned conn)' , ( done ) => {
340
+ swarmB . handle ( '/apples/1.0.0' , ( conn ) => {
341
+ conn . pipe ( conn )
342
+ } )
343
+
344
+ const conn = swarmA . dial ( peerB , '/apples/1.0.0' , ( err ) => {
345
+ expect ( err ) . to . not . exist
346
+ } )
347
+ conn . end ( )
348
+ conn . on ( 'data' , ( ) => { } ) // let it flow.. let it flooooow
349
+ conn . on ( 'end' , done )
350
+ } )
351
+
326
352
it ( 'dial to warm a conn' , ( done ) => {
327
353
swarmA . dial ( peerB , ( err ) => {
328
354
expect ( err ) . to . not . exist
@@ -605,6 +631,21 @@ describe('high level API - with everything mixed all together!', function () {
605
631
} )
606
632
} )
607
633
634
+ it ( 'dial from tcp to tcp+ws (returned conn)' , ( done ) => {
635
+ swarmB . handle ( '/grapes/1.0.0' , ( conn ) => {
636
+ conn . pipe ( conn )
637
+ } )
638
+
639
+ const conn = swarmA . dial ( peerB , '/grapes/1.0.0' , ( err , conn ) => {
640
+ expect ( err ) . to . not . exist
641
+ expect ( Object . keys ( swarmA . muxedConns ) . length ) . to . equal ( 1 )
642
+ } )
643
+ conn . end ( )
644
+
645
+ conn . on ( 'data' , ( ) => { } ) // let it flow.. let it flooooow
646
+ conn . on ( 'end' , done )
647
+ } )
648
+
608
649
it ( 'dial from tcp+ws to tcp+ws' , ( done ) => {
609
650
swarmC . handle ( '/mamao/1.0.0' , ( conn ) => {
610
651
conn . pipe ( conn )
0 commit comments