@@ -83,7 +83,7 @@ const net = require('net');
8383 }
8484 } , expectedConnections ) ) ;
8585
86- server . listen ( 0 , 'localhost' , common . mustCall ( ( ) => {
86+ server . listen ( 0 , common . localhostIPv4 , common . mustCall ( ( ) => {
8787 const port = server . address ( ) . port ;
8888
8989 // Total connections = 3 * 4(canConnect) * 6(doConnect) = 72
@@ -133,28 +133,35 @@ function doConnect(args, getCb) {
133133}
134134
135135function syncFailToConnect ( port , assertErr , optOnly ) {
136+ const family = 4 ;
136137 if ( ! optOnly ) {
137138 // connect(port, cb) and connect(port)
138- const portArgFunctions = doConnect ( [ port ] , ( ) => common . mustNotCall ( ) ) ;
139+ const portArgFunctions = doConnect ( [ { port, family } ] ,
140+ ( ) => common . mustNotCall ( ) ) ;
139141 for ( const fn of portArgFunctions ) {
140142 assert . throws ( fn , assertErr , `${ fn . name } (${ port } )` ) ;
141143 }
142144
143145 // connect(port, host, cb) and connect(port, host)
144- const portHostArgFunctions = doConnect ( [ port , 'localhost' ] ,
146+ const portHostArgFunctions = doConnect ( [ { port,
147+ host : 'localhost' ,
148+ family } ] ,
145149 ( ) => common . mustNotCall ( ) ) ;
146150 for ( const fn of portHostArgFunctions ) {
147151 assert . throws ( fn , assertErr , `${ fn . name } (${ port } , 'localhost')` ) ;
148152 }
149153 }
150154 // connect({port}, cb) and connect({port})
151- const portOptFunctions = doConnect ( [ { port } ] , ( ) => common . mustNotCall ( ) ) ;
155+ const portOptFunctions = doConnect ( [ { port, family } ] ,
156+ ( ) => common . mustNotCall ( ) ) ;
152157 for ( const fn of portOptFunctions ) {
153158 assert . throws ( fn , assertErr , `${ fn . name } ({port: ${ port } })` ) ;
154159 }
155160
156161 // 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 } ] ,
158165 ( ) => common . mustNotCall ( ) ) ;
159166 for ( const fn of portHostOptFunctions ) {
160167 assert . throws ( fn ,
@@ -165,27 +172,30 @@ function syncFailToConnect(port, assertErr, optOnly) {
165172
166173function canConnect ( port ) {
167174 const noop = ( ) => common . mustCall ( ) ;
175+ const family = 4 ;
168176
169177 // connect(port, cb) and connect(port)
170- const portArgFunctions = doConnect ( [ port ] , noop ) ;
178+ const portArgFunctions = doConnect ( [ { port, family } ] , noop ) ;
171179 for ( const fn of portArgFunctions ) {
172180 fn ( ) ;
173181 }
174182
175183 // 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 ) ;
177186 for ( const fn of portHostArgFunctions ) {
178187 fn ( ) ;
179188 }
180189
181190 // connect({port}, cb) and connect({port})
182- const portOptFunctions = doConnect ( [ { port } ] , noop ) ;
191+ const portOptFunctions = doConnect ( [ { port, family } ] , noop ) ;
183192 for ( const fn of portOptFunctions ) {
184193 fn ( ) ;
185194 }
186195
187196 // 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 ) ;
189199 for ( const fn of portHostOptFns ) {
190200 fn ( ) ;
191201 }
@@ -198,20 +208,22 @@ function asyncFailToConnect(port) {
198208 } ) ;
199209
200210 const dont = ( ) => common . mustNotCall ( ) ;
211+ const family = 4 ;
201212 // connect(port, cb) and connect(port)
202- const portArgFunctions = doConnect ( [ port ] , dont ) ;
213+ const portArgFunctions = doConnect ( [ { port, family } ] , dont ) ;
203214 for ( const fn of portArgFunctions ) {
204215 fn ( ) . on ( 'error' , onError ( ) ) ;
205216 }
206217
207218 // connect({port}, cb) and connect({port})
208- const portOptFunctions = doConnect ( [ { port } ] , dont ) ;
219+ const portOptFunctions = doConnect ( [ { port, family } ] , dont ) ;
209220 for ( const fn of portOptFunctions ) {
210221 fn ( ) . on ( 'error' , onError ( ) ) ;
211222 }
212223
213224 // 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 ) ;
215227 for ( const fn of portHostOptFns ) {
216228 fn ( ) . on ( 'error' , onError ( ) ) ;
217229 }
0 commit comments