@@ -83,7 +83,7 @@ const net = require('net');
83
83
}
84
84
} , expectedConnections ) ) ;
85
85
86
- server . listen ( 0 , 'localhost' , common . mustCall ( ( ) => {
86
+ server . listen ( 0 , common . localhostIPv4 , common . mustCall ( ( ) => {
87
87
const port = server . address ( ) . port ;
88
88
89
89
// Total connections = 3 * 4(canConnect) * 6(doConnect) = 72
@@ -133,28 +133,35 @@ function doConnect(args, getCb) {
133
133
}
134
134
135
135
function syncFailToConnect ( port , assertErr , optOnly ) {
136
+ const family = 4 ;
136
137
if ( ! optOnly ) {
137
138
// connect(port, cb) and connect(port)
138
- const portArgFunctions = doConnect ( [ port ] , ( ) => common . mustNotCall ( ) ) ;
139
+ const portArgFunctions = doConnect ( [ { port, family } ] ,
140
+ ( ) => common . mustNotCall ( ) ) ;
139
141
for ( const fn of portArgFunctions ) {
140
142
assert . throws ( fn , assertErr , `${ fn . name } (${ port } )` ) ;
141
143
}
142
144
143
145
// connect(port, host, cb) and connect(port, host)
144
- const portHostArgFunctions = doConnect ( [ port , 'localhost' ] ,
146
+ const portHostArgFunctions = doConnect ( [ { port,
147
+ host : 'localhost' ,
148
+ family } ] ,
145
149
( ) => common . mustNotCall ( ) ) ;
146
150
for ( const fn of portHostArgFunctions ) {
147
151
assert . throws ( fn , assertErr , `${ fn . name } (${ port } , 'localhost')` ) ;
148
152
}
149
153
}
150
154
// connect({port}, cb) and connect({port})
151
- const portOptFunctions = doConnect ( [ { port } ] , ( ) => common . mustNotCall ( ) ) ;
155
+ const portOptFunctions = doConnect ( [ { port, family } ] ,
156
+ ( ) => common . mustNotCall ( ) ) ;
152
157
for ( const fn of portOptFunctions ) {
153
158
assert . throws ( fn , assertErr , `${ fn . name } ({port: ${ port } })` ) ;
154
159
}
155
160
156
161
// connect({port, host}, cb) and connect({port, host})
157
- const portHostOptFunctions = doConnect ( [ { port : port , host : 'localhost' } ] ,
162
+ const portHostOptFunctions = doConnect ( [ { port : port ,
163
+ host : 'localhost' ,
164
+ family : family } ] ,
158
165
( ) => common . mustNotCall ( ) ) ;
159
166
for ( const fn of portHostOptFunctions ) {
160
167
assert . throws ( fn ,
@@ -165,27 +172,30 @@ function syncFailToConnect(port, assertErr, optOnly) {
165
172
166
173
function canConnect ( port ) {
167
174
const noop = ( ) => common . mustCall ( ) ;
175
+ const family = 4 ;
168
176
169
177
// connect(port, cb) and connect(port)
170
- const portArgFunctions = doConnect ( [ port ] , noop ) ;
178
+ const portArgFunctions = doConnect ( [ { port, family } ] , noop ) ;
171
179
for ( const fn of portArgFunctions ) {
172
180
fn ( ) ;
173
181
}
174
182
175
183
// connect(port, host, cb) and connect(port, host)
176
- const portHostArgFunctions = doConnect ( [ port , 'localhost' ] , noop ) ;
184
+ const portHostArgFunctions = doConnect ( [ { port, host : 'localhost' , family } ] ,
185
+ noop ) ;
177
186
for ( const fn of portHostArgFunctions ) {
178
187
fn ( ) ;
179
188
}
180
189
181
190
// connect({port}, cb) and connect({port})
182
- const portOptFunctions = doConnect ( [ { port } ] , noop ) ;
191
+ const portOptFunctions = doConnect ( [ { port, family } ] , noop ) ;
183
192
for ( const fn of portOptFunctions ) {
184
193
fn ( ) ;
185
194
}
186
195
187
196
// connect({port, host}, cb) and connect({port, host})
188
- const portHostOptFns = doConnect ( [ { port, host : 'localhost' } ] , noop ) ;
197
+ const portHostOptFns = doConnect ( [ { port, host : 'localhost' , family } ] ,
198
+ noop ) ;
189
199
for ( const fn of portHostOptFns ) {
190
200
fn ( ) ;
191
201
}
@@ -198,20 +208,22 @@ function asyncFailToConnect(port) {
198
208
} ) ;
199
209
200
210
const dont = ( ) => common . mustNotCall ( ) ;
211
+ const family = 4 ;
201
212
// connect(port, cb) and connect(port)
202
- const portArgFunctions = doConnect ( [ port ] , dont ) ;
213
+ const portArgFunctions = doConnect ( [ { port, family } ] , dont ) ;
203
214
for ( const fn of portArgFunctions ) {
204
215
fn ( ) . on ( 'error' , onError ( ) ) ;
205
216
}
206
217
207
218
// connect({port}, cb) and connect({port})
208
- const portOptFunctions = doConnect ( [ { port } ] , dont ) ;
219
+ const portOptFunctions = doConnect ( [ { port, family } ] , dont ) ;
209
220
for ( const fn of portOptFunctions ) {
210
221
fn ( ) . on ( 'error' , onError ( ) ) ;
211
222
}
212
223
213
224
// connect({port, host}, cb) and connect({port, host})
214
- const portHostOptFns = doConnect ( [ { port, host : 'localhost' } ] , dont ) ;
225
+ const portHostOptFns = doConnect ( [ { port, host : 'localhost' , family } ] ,
226
+ dont ) ;
215
227
for ( const fn of portHostOptFns ) {
216
228
fn ( ) . on ( 'error' , onError ( ) ) ;
217
229
}
0 commit comments