@@ -8,7 +8,6 @@ const pump = require('pump')
8
8
const { Writable } = require ( 'stream' )
9
9
const series = require ( 'async/series' )
10
10
const { spawnNodesWithId } = require ( './utils/spawn' )
11
- const { waitUntilConnected } = require ( './utils/connections' )
12
11
13
12
const expect = chai . expect
14
13
chai . use ( dirtyChai )
@@ -29,8 +28,8 @@ function isPong (pingResponse) {
29
28
30
29
module . exports = ( common ) => {
31
30
describe ( '.ping' , function ( ) {
32
- let ipfsdA
33
- let ipfsdB
31
+ let ipfsA
32
+ let ipfsB
34
33
35
34
before ( function ( done ) {
36
35
this . timeout ( 60 * 1000 )
@@ -42,12 +41,12 @@ module.exports = (common) => {
42
41
( cb ) => {
43
42
spawnNodesWithId ( 2 , factory , ( err , nodes ) => {
44
43
if ( err ) return cb ( err )
45
- ipfsdA = nodes [ 0 ]
46
- ipfsdB = nodes [ 1 ]
44
+ ipfsA = nodes [ 0 ]
45
+ ipfsB = nodes [ 1 ]
47
46
cb ( )
48
47
} )
49
48
} ,
50
- ( cb ) => waitUntilConnected ( ipfsdA , ipfsdB , cb )
49
+ ( cb ) => ipfsA . swarm . connect ( ipfsB . peerId . addresses [ 0 ] , cb )
51
50
] , done )
52
51
} )
53
52
} )
@@ -59,7 +58,7 @@ module.exports = (common) => {
59
58
60
59
it ( 'sends the specified number of packets' , ( done ) => {
61
60
const count = 3
62
- ipfsdA . ping ( ipfsdB . peerId . id , { count } , ( err , responses ) => {
61
+ ipfsA . ping ( ipfsB . peerId . id , { count } , ( err , responses ) => {
63
62
expect ( err ) . to . not . exist ( )
64
63
responses . forEach ( expectIsPingResponse )
65
64
const pongs = responses . filter ( isPong )
@@ -72,7 +71,7 @@ module.exports = (common) => {
72
71
const unknownPeerId = 'QmUmaEnH1uMmvckMZbh3yShaasvELPW4ZLPWnB4entMTEn'
73
72
const count = 2
74
73
75
- ipfsdA . ping ( unknownPeerId , { count } , ( err , responses ) => {
74
+ ipfsA . ping ( unknownPeerId , { count } , ( err , responses ) => {
76
75
expect ( err ) . to . exist ( )
77
76
expect ( responses [ 0 ] . text ) . to . include ( 'Looking up' )
78
77
expect ( responses [ 1 ] . success ) . to . be . false ( )
@@ -83,7 +82,7 @@ module.exports = (common) => {
83
82
it ( 'fails when pinging an invalid peer' , ( done ) => {
84
83
const invalidPeerId = 'not a peer ID'
85
84
const count = 2
86
- ipfsdA . ping ( invalidPeerId , { count } , ( err , responses ) => {
85
+ ipfsA . ping ( invalidPeerId , { count } , ( err , responses ) => {
87
86
expect ( err ) . to . exist ( )
88
87
expect ( err . message ) . to . include ( 'failed to parse peer address' )
89
88
done ( )
@@ -98,7 +97,7 @@ module.exports = (common) => {
98
97
let packetNum = 0
99
98
const count = 3
100
99
pull (
101
- ipfsdA . pingPullStream ( ipfsdB . peerId . id , { count } ) ,
100
+ ipfsA . pingPullStream ( ipfsB . peerId . id , { count } ) ,
102
101
pull . drain ( ( res ) => {
103
102
expect ( res . success ) . to . be . true ( )
104
103
// It's a pong
@@ -118,7 +117,7 @@ module.exports = (common) => {
118
117
const unknownPeerId = 'QmUmaEnH1uMmvckMZbh3yShaasvELPW4ZLPWnB4entMTEn'
119
118
const count = 2
120
119
pull (
121
- ipfsdA . pingPullStream ( unknownPeerId , { count } ) ,
120
+ ipfsA . pingPullStream ( unknownPeerId , { count } ) ,
122
121
pull . drain ( ( res ) => {
123
122
expectIsPingResponse ( res )
124
123
messageNum ++
@@ -143,7 +142,7 @@ module.exports = (common) => {
143
142
const invalidPeerId = 'not a peer ID'
144
143
const count = 2
145
144
pull (
146
- ipfsdA . pingPullStream ( invalidPeerId , { count } ) ,
145
+ ipfsA . pingPullStream ( invalidPeerId , { count } ) ,
147
146
pull . collect ( ( err ) => {
148
147
expect ( err ) . to . exist ( )
149
148
expect ( err . message ) . to . include ( 'failed to parse peer address' )
@@ -161,7 +160,7 @@ module.exports = (common) => {
161
160
const count = 3
162
161
163
162
pump (
164
- ipfsdA . pingReadableStream ( ipfsdB . peerId . id , { count } ) ,
163
+ ipfsA . pingReadableStream ( ipfsB . peerId . id , { count } ) ,
165
164
new Writable ( {
166
165
objectMode : true ,
167
166
write ( res , enc , cb ) {
@@ -188,7 +187,7 @@ module.exports = (common) => {
188
187
const count = 2
189
188
190
189
pump (
191
- ipfsdA . pingReadableStream ( unknownPeerId , { count } ) ,
190
+ ipfsA . pingReadableStream ( unknownPeerId , { count } ) ,
192
191
new Writable ( {
193
192
objectMode : true ,
194
193
write ( res , enc , cb ) {
@@ -220,7 +219,7 @@ module.exports = (common) => {
220
219
const count = 2
221
220
222
221
pump (
223
- ipfsdA . pingReadableStream ( invalidPeerId , { count } ) ,
222
+ ipfsA . pingReadableStream ( invalidPeerId , { count } ) ,
224
223
new Writable ( {
225
224
objectMode : true ,
226
225
write : ( chunk , enc , cb ) => cb ( )
0 commit comments