@@ -548,6 +548,21 @@ describe('variants', () => {
548
548
expect ( addr ) . to . have . property ( 'bytes' )
549
549
expect ( addr . toString ( ) ) . to . equal ( str )
550
550
} )
551
+
552
+ it ( 'ip4 + tcp + http + retrieval' , ( ) => {
553
+ const str = '/ip4/127.0.0.1/tcp/8000/http/retrieval/http'
554
+ const addr = multiaddr ( str )
555
+ expect ( addr ) . to . have . property ( 'bytes' )
556
+ expect ( addr . toString ( ) ) . to . equal ( str )
557
+ } )
558
+
559
+ it ( 'ws + p2p + retrieval tuple' , ( ) => {
560
+ const str =
561
+ '/ip4/127.0.0.1/tcp/9090/ws/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/retrieval/bitswap/retrieval/graphsync'
562
+ const addr = multiaddr ( str )
563
+ expect ( addr ) . to . have . property ( 'bytes' )
564
+ expect ( addr . toString ( ) ) . to . equal ( str )
565
+ } )
551
566
} )
552
567
553
568
describe ( 'helpers' , ( ) => {
@@ -732,6 +747,26 @@ describe('helpers', () => {
732
747
] )
733
748
} )
734
749
750
+ it ( 'returns the tuples for retrieval' , ( ) => {
751
+ expect ( multiaddr ( '/ip4/127.0.0.1/tcp/8000/http/retrieval/http' ) . tuples ( ) )
752
+ . to . eql ( [
753
+ [ 4 , Uint8Array . from ( [ 127 , 0 , 0 , 1 ] ) ] ,
754
+ [ 6 , Uint8Array . from ( [ 31 , 64 ] ) ] ,
755
+ [ 480 ] ,
756
+ [ 496 , Uint8Array . from ( [ 4 , 104 , 116 , 116 , 112 ] ) ]
757
+ ] )
758
+
759
+ expect ( multiaddr ( '/ip4/127.0.0.1/tcp/9090/ws/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/retrieval/bitswap/retrieval/graphsync' ) . tuples ( ) )
760
+ . to . eql ( [
761
+ [ 4 , Uint8Array . from ( [ 127 , 0 , 0 , 1 ] ) ] ,
762
+ [ 6 , Uint8Array . from ( [ 35 , 130 ] ) ] ,
763
+ [ 477 ] ,
764
+ [ 421 , Uint8Array . from ( [ 34 , 18 , 32 , 213 , 46 , 187 , 137 , 216 , 91 , 2 , 162 , 132 , 148 , 130 , 3 , 166 , 47 , 242 , 131 , 137 , 197 , 124 , 159 , 66 , 190 , 236 , 78 , 194 , 13 , 183 , 106 , 104 , 145 , 28 , 11 ] ) ] ,
765
+ [ 496 , Uint8Array . from ( [ 7 , 98 , 105 , 116 , 115 , 119 , 97 , 112 ] ) ] ,
766
+ [ 496 , Uint8Array . from ( [ 9 , 103 , 114 , 97 , 112 , 104 , 115 , 121 , 110 , 99 ] ) ]
767
+ ] )
768
+ } )
769
+
735
770
it ( 'does not allow modifying parts' , ( ) => {
736
771
const ma = multiaddr ( '/ip4/0.0.0.0/tcp/1234' )
737
772
const tuples = ma . tuples ( )
@@ -742,14 +777,34 @@ describe('helpers', () => {
742
777
} )
743
778
744
779
describe ( '.stringTuples' , ( ) => {
745
- it ( 'returns the string partss ' , ( ) => {
780
+ it ( 'returns the string parts ' , ( ) => {
746
781
expect ( multiaddr ( '/ip4/0.0.0.0/utp' ) . stringTuples ( ) )
747
782
. to . eql ( [
748
783
[ 4 , '0.0.0.0' ] ,
749
784
[ 302 ]
750
785
] )
751
786
} )
752
787
788
+ it ( 'returns the string parts for retrieval' , ( ) => {
789
+ expect ( multiaddr ( '/ip4/127.0.0.1/tcp/8000/http/retrieval/http' ) . stringTuples ( ) )
790
+ . to . eql ( [
791
+ [ 4 , '127.0.0.1' ] ,
792
+ [ 6 , '8000' ] ,
793
+ [ 480 ] ,
794
+ [ 496 , 'http' ]
795
+ ] )
796
+
797
+ expect ( multiaddr ( '/ip4/127.0.0.1/tcp/9090/ws/p2p/QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC/retrieval/bitswap/retrieval/graphsync' ) . stringTuples ( ) )
798
+ . to . eql ( [
799
+ [ 4 , '127.0.0.1' ] ,
800
+ [ 6 , '9090' ] ,
801
+ [ 477 ] ,
802
+ [ 421 , 'QmcgpsyWgH8Y8ajJz1Cu72KnS5uo2Aa2LpzU7kinSupNKC' ] ,
803
+ [ 496 , 'bitswap' ] ,
804
+ [ 496 , 'graphsync' ]
805
+ ] )
806
+ } )
807
+
753
808
it ( 'does not allow modifying string parts' , ( ) => {
754
809
const ma = multiaddr ( '/ip4/0.0.0.0/tcp/1234' )
755
810
const tuples = ma . stringTuples ( )
0 commit comments