@@ -8,7 +8,6 @@ const pump = require('pump')
88const { Writable } = require ( 'stream' )
99const series = require ( 'async/series' )
1010const { spawnNodesWithId } = require ( './utils/spawn' )
11- const { waitUntilConnected } = require ( './utils/connections' )
1211
1312const expect = chai . expect
1413chai . use ( dirtyChai )
@@ -29,8 +28,8 @@ function isPong (pingResponse) {
2928
3029module . exports = ( common ) => {
3130 describe ( '.ping' , function ( ) {
32- let ipfsdA
33- let ipfsdB
31+ let ipfsA
32+ let ipfsB
3433
3534 before ( function ( done ) {
3635 this . timeout ( 60 * 1000 )
@@ -42,12 +41,12 @@ module.exports = (common) => {
4241 ( cb ) => {
4342 spawnNodesWithId ( 2 , factory , ( err , nodes ) => {
4443 if ( err ) return cb ( err )
45- ipfsdA = nodes [ 0 ]
46- ipfsdB = nodes [ 1 ]
44+ ipfsA = nodes [ 0 ]
45+ ipfsB = nodes [ 1 ]
4746 cb ( )
4847 } )
4948 } ,
50- ( cb ) => waitUntilConnected ( ipfsdA , ipfsdB , cb )
49+ ( cb ) => ipfsA . swarm . connect ( ipfsB . peerId . addresses [ 0 ] , cb )
5150 ] , done )
5251 } )
5352 } )
@@ -59,7 +58,7 @@ module.exports = (common) => {
5958
6059 it ( 'sends the specified number of packets' , ( done ) => {
6160 const count = 3
62- ipfsdA . ping ( ipfsdB . peerId . id , { count } , ( err , responses ) => {
61+ ipfsA . ping ( ipfsB . peerId . id , { count } , ( err , responses ) => {
6362 expect ( err ) . to . not . exist ( )
6463 responses . forEach ( expectIsPingResponse )
6564 const pongs = responses . filter ( isPong )
@@ -72,7 +71,7 @@ module.exports = (common) => {
7271 const unknownPeerId = 'QmUmaEnH1uMmvckMZbh3yShaasvELPW4ZLPWnB4entMTEn'
7372 const count = 2
7473
75- ipfsdA . ping ( unknownPeerId , { count } , ( err , responses ) => {
74+ ipfsA . ping ( unknownPeerId , { count } , ( err , responses ) => {
7675 expect ( err ) . to . exist ( )
7776 expect ( responses [ 0 ] . text ) . to . include ( 'Looking up' )
7877 expect ( responses [ 1 ] . success ) . to . be . false ( )
@@ -83,7 +82,7 @@ module.exports = (common) => {
8382 it ( 'fails when pinging an invalid peer' , ( done ) => {
8483 const invalidPeerId = 'not a peer ID'
8584 const count = 2
86- ipfsdA . ping ( invalidPeerId , { count } , ( err , responses ) => {
85+ ipfsA . ping ( invalidPeerId , { count } , ( err , responses ) => {
8786 expect ( err ) . to . exist ( )
8887 expect ( err . message ) . to . include ( 'failed to parse peer address' )
8988 done ( )
@@ -98,7 +97,7 @@ module.exports = (common) => {
9897 let packetNum = 0
9998 const count = 3
10099 pull (
101- ipfsdA . pingPullStream ( ipfsdB . peerId . id , { count } ) ,
100+ ipfsA . pingPullStream ( ipfsB . peerId . id , { count } ) ,
102101 pull . drain ( ( res ) => {
103102 expect ( res . success ) . to . be . true ( )
104103 // It's a pong
@@ -118,7 +117,7 @@ module.exports = (common) => {
118117 const unknownPeerId = 'QmUmaEnH1uMmvckMZbh3yShaasvELPW4ZLPWnB4entMTEn'
119118 const count = 2
120119 pull (
121- ipfsdA . pingPullStream ( unknownPeerId , { count } ) ,
120+ ipfsA . pingPullStream ( unknownPeerId , { count } ) ,
122121 pull . drain ( ( res ) => {
123122 expectIsPingResponse ( res )
124123 messageNum ++
@@ -143,7 +142,7 @@ module.exports = (common) => {
143142 const invalidPeerId = 'not a peer ID'
144143 const count = 2
145144 pull (
146- ipfsdA . pingPullStream ( invalidPeerId , { count } ) ,
145+ ipfsA . pingPullStream ( invalidPeerId , { count } ) ,
147146 pull . collect ( ( err ) => {
148147 expect ( err ) . to . exist ( )
149148 expect ( err . message ) . to . include ( 'failed to parse peer address' )
@@ -161,7 +160,7 @@ module.exports = (common) => {
161160 const count = 3
162161
163162 pump (
164- ipfsdA . pingReadableStream ( ipfsdB . peerId . id , { count } ) ,
163+ ipfsA . pingReadableStream ( ipfsB . peerId . id , { count } ) ,
165164 new Writable ( {
166165 objectMode : true ,
167166 write ( res , enc , cb ) {
@@ -188,7 +187,7 @@ module.exports = (common) => {
188187 const count = 2
189188
190189 pump (
191- ipfsdA . pingReadableStream ( unknownPeerId , { count } ) ,
190+ ipfsA . pingReadableStream ( unknownPeerId , { count } ) ,
192191 new Writable ( {
193192 objectMode : true ,
194193 write ( res , enc , cb ) {
@@ -220,7 +219,7 @@ module.exports = (common) => {
220219 const count = 2
221220
222221 pump (
223- ipfsdA . pingReadableStream ( invalidPeerId , { count } ) ,
222+ ipfsA . pingReadableStream ( invalidPeerId , { count } ) ,
224223 new Writable ( {
225224 objectMode : true ,
226225 write : ( chunk , enc , cb ) => cb ( )
0 commit comments