@@ -443,11 +443,11 @@ describe('helpers', () => {
443
443
} )
444
444
445
445
describe ( '.nodeAddress' , ( ) => {
446
- it ( 'throws on non thinWaistAddress ' , ( ) => {
446
+ it ( 'throws on an invalid node address ' , ( ) => {
447
447
expect (
448
448
( ) => multiaddr ( '/ip4/192.168.0.1/utp' ) . nodeAddress ( )
449
449
) . to . throw (
450
- / t h i n w a i s t /
450
+ / m u l t i a d d r m u s t h a v e a v a l i d f o r m a t /
451
451
)
452
452
} )
453
453
@@ -456,10 +456,44 @@ describe('helpers', () => {
456
456
multiaddr ( '/ip4/192.168.0.1/tcp/1234' ) . nodeAddress ( )
457
457
) . to . be . eql ( {
458
458
address : '192.168.0.1' ,
459
- family : 'IPv4' ,
459
+ family : 4 ,
460
460
port : '1234'
461
461
} )
462
462
} )
463
+
464
+ it ( 'returns a node friendly address with dns' , ( ) => {
465
+ expect (
466
+ multiaddr ( '/dns4/wss0.bootstrap.libp2p.io/tcp/443' ) . nodeAddress ( )
467
+ ) . to . be . eql ( {
468
+ address : 'wss0.bootstrap.libp2p.io' ,
469
+ family : 4 ,
470
+ port : '443'
471
+ } )
472
+ } )
473
+
474
+ it ( 'throws on an invalid format address when the addr is not prefixed with a /' , ( ) => {
475
+ expect (
476
+ ( ) => multiaddr ( 'ip4/192.168.0.1/udp' ) . nodeAddress ( )
477
+ ) . to . throw (
478
+ / m u s t s t a r t w i t h a /
479
+ )
480
+ } )
481
+
482
+ it ( 'throws on an invalid protocol name when the addr has an invalid one' , ( ) => {
483
+ expect (
484
+ ( ) => multiaddr ( '/ip5/127.0.0.1/udp/5000' )
485
+ ) . to . throw (
486
+ / n o p r o t o c o l w i t h n a m e /
487
+ )
488
+ } )
489
+
490
+ it ( 'throws on an invalid protocol name when the transport protocol is not valid' , ( ) => {
491
+ expect (
492
+ ( ) => multiaddr ( '/ip4/127.0.0.1/utp/5000' )
493
+ ) . to . throw (
494
+ / n o p r o t o c o l w i t h n a m e /
495
+ )
496
+ } )
463
497
} )
464
498
465
499
describe ( '.fromNodeAddress' , ( ) => {
@@ -501,10 +535,10 @@ describe('helpers', () => {
501
535
}
502
536
families . forEach ( ( family ) => {
503
537
transports . forEach ( ( transport ) => {
504
- it ( `returns true for ${ family } -${ transport } ` , ( ) => {
538
+ it ( `returns true for / ${ family } -${ transport } ` , ( ) => {
505
539
expect (
506
540
multiaddr (
507
- `${ family } /${ addresses [ family ] } /${ transport } /1234`
541
+ `/ ${ family } /${ addresses [ family ] } /${ transport } /1234`
508
542
) . isThinWaistAddress ( )
509
543
) . to . equal ( true )
510
544
} )
0 commit comments