@@ -21,7 +21,7 @@ describe.skip('.swarm.peers', function () {
2121 const res = await ipfs . swarm . peers ( )
2222
2323 expect ( res ) . to . be . a ( 'array' )
24- expect ( res . length ) . to . equal ( 1 )
24+ expect ( res . length ) . to . be . greaterThan ( 0 )
2525 expect ( res [ 0 ] . error ) . to . not . exist ( )
2626 expect ( res [ 0 ] . addr . toString ( ) ) . to . equal ( response . Peers [ 0 ] . Addr )
2727 expect ( res [ 0 ] . peer . toString ( ) ) . to . equal ( response . Peers [ 0 ] . Peer )
@@ -39,7 +39,7 @@ describe.skip('.swarm.peers', function () {
3939 const res = await ipfs . swarm . peers ( )
4040
4141 expect ( res ) . to . be . a ( 'array' )
42- expect ( res . length ) . to . equal ( 1 )
42+ expect ( res . length ) . to . be . greaterThan ( 0 )
4343 expect ( res [ 0 ] . error ) . to . not . exist ( )
4444 expect ( res [ 0 ] . addr . toString ( ) ) . to . equal ( response . Peers [ 0 ] . Addr )
4545 expect ( res [ 0 ] . peer . toString ( ) ) . to . equal ( response . Peers [ 0 ] . Peer )
@@ -56,4 +56,38 @@ describe.skip('.swarm.peers', function () {
5656
5757 expect ( scope . isDone ( ) ) . to . equal ( true )
5858 } )
59+
60+ it ( 'handles a peer response with identify option' , async function ( ) {
61+ const response = {
62+ Peers : [ {
63+ Addr : '/ip4/104.131.131.82/tcp/4001' ,
64+ Peer : 'QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ' ,
65+ Latency : '10ms' ,
66+ Muxer : '' ,
67+ Streams : null ,
68+ Identify : {
69+ ID : 'QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ' ,
70+ PublicKey : 'CAESIBase64Key...' ,
71+ Addresses : [ '/ip4/104.131.131.82/tcp/4001' ] ,
72+ AgentVersion : 'kubo/0.35.0' ,
73+ Protocols : [ '/ipfs/id/1.0.0' , '/ipfs/kad/1.0.0' ]
74+ }
75+ } ]
76+ }
77+
78+ const scope = nock ( apiUrl )
79+ . post ( '/api/v0/swarm/peers' )
80+ . query ( { identify : true } )
81+ . reply ( 200 , response )
82+
83+ const res = await ipfs . swarm . peers ( { identify : true } )
84+
85+ expect ( res ) . to . be . a ( 'array' )
86+ expect ( res . length ) . to . be . greaterThan ( 0 )
87+ expect ( res [ 0 ] . identify ) . to . exist ( )
88+ expect ( res [ 0 ] . identify ?. AgentVersion ) . to . equal ( 'kubo/0.35.0' )
89+ expect ( res [ 0 ] . identify ?. ID ) . to . equal ( response . Peers [ 0 ] . Identify . ID )
90+ expect ( res [ 0 ] . identify ?. Protocols ) . to . deep . equal ( response . Peers [ 0 ] . Identify . Protocols )
91+ expect ( scope . isDone ( ) ) . to . equal ( true )
92+ } )
5993} )
0 commit comments