@@ -30,15 +30,16 @@ test(function serverTimeout(cb) {
3030 var server = http . createServer ( function ( req , res ) {
3131 // just do nothing, we should get a timeout event.
3232 } ) ;
33- server . listen ( common . PORT ) ;
33+ server . listen ( common . mustCall ( function ( ) {
34+ http . get ( { port : server . address ( ) . port } ) . on ( 'error' , function ( ) { } ) ;
35+ } ) ) ;
3436 var s = server . setTimeout ( 50 , function ( socket ) {
3537 caughtTimeout = true ;
3638 socket . destroy ( ) ;
3739 server . close ( ) ;
3840 cb ( ) ;
3941 } ) ;
4042 assert . ok ( s instanceof http . Server ) ;
41- http . get ( { port : common . PORT } ) . on ( 'error' , function ( ) { } ) ;
4243} ) ;
4344
4445test ( function serverRequestTimeout ( cb ) {
@@ -56,11 +57,13 @@ test(function serverRequestTimeout(cb) {
5657 } ) ;
5758 assert . ok ( s instanceof http . IncomingMessage ) ;
5859 } ) ;
59- server . listen ( common . PORT ) ;
60- var req = http . request ( { port : common . PORT , method : 'POST' } ) ;
61- req . on ( 'error' , function ( ) { } ) ;
62- req . write ( 'Hello' ) ;
63- // req is in progress
60+ server . listen ( common . mustCall ( function ( ) {
61+ var port = server . address ( ) . port ;
62+ var req = http . request ( { port : port , method : 'POST' } ) ;
63+ req . on ( 'error' , function ( ) { } ) ;
64+ req . write ( 'Hello' ) ;
65+ // req is in progress
66+ } ) ) ;
6467} ) ;
6568
6669test ( function serverResponseTimeout ( cb ) {
@@ -78,8 +81,10 @@ test(function serverResponseTimeout(cb) {
7881 } ) ;
7982 assert . ok ( s instanceof http . OutgoingMessage ) ;
8083 } ) ;
81- server . listen ( common . PORT ) ;
82- http . get ( { port : common . PORT } ) . on ( 'error' , function ( ) { } ) ;
84+ server . listen ( common . mustCall ( function ( ) {
85+ var port = server . address ( ) . port ;
86+ http . get ( { port : port } ) . on ( 'error' , function ( ) { } ) ;
87+ } ) ) ;
8388} ) ;
8489
8590test ( function serverRequestNotTimeoutAfterEnd ( cb ) {
@@ -104,8 +109,10 @@ test(function serverRequestNotTimeoutAfterEnd(cb) {
104109 server . close ( ) ;
105110 cb ( ) ;
106111 } ) ;
107- server . listen ( common . PORT ) ;
108- http . get ( { port : common . PORT } ) . on ( 'error' , function ( ) { } ) ;
112+ server . listen ( common . mustCall ( function ( ) {
113+ var port = server . address ( ) . port ;
114+ http . get ( { port : port } ) . on ( 'error' , function ( ) { } ) ;
115+ } ) ) ;
109116} ) ;
110117
111118test ( function serverResponseTimeoutWithPipeline ( cb ) {
@@ -125,12 +132,14 @@ test(function serverResponseTimeoutWithPipeline(cb) {
125132 server . close ( ) ;
126133 cb ( ) ;
127134 } ) ;
128- server . listen ( common . PORT ) ;
129- var c = net . connect ( { port : common . PORT , allowHalfOpen : true } , function ( ) {
130- c . write ( 'GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n' ) ;
131- c . write ( 'GET /2 HTTP/1.1\r\nHost: localhost\r\n\r\n' ) ;
132- c . write ( 'GET /3 HTTP/1.1\r\nHost: localhost\r\n\r\n' ) ;
133- } ) ;
135+ server . listen ( common . mustCall ( function ( ) {
136+ var port = server . address ( ) . port ;
137+ var c = net . connect ( { port : port , allowHalfOpen : true } , function ( ) {
138+ c . write ( 'GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n' ) ;
139+ c . write ( 'GET /2 HTTP/1.1\r\nHost: localhost\r\n\r\n' ) ;
140+ c . write ( 'GET /3 HTTP/1.1\r\nHost: localhost\r\n\r\n' ) ;
141+ } ) ;
142+ } ) ) ;
134143} ) ;
135144
136145test ( function idleTimeout ( cb ) {
@@ -158,9 +167,11 @@ test(function idleTimeout(cb) {
158167 cb ( ) ;
159168 } ) ;
160169 assert . ok ( s instanceof http . Server ) ;
161- server . listen ( common . PORT ) ;
162- var c = net . connect ( { port : common . PORT , allowHalfOpen : true } , function ( ) {
163- c . write ( 'GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n' ) ;
164- // Keep-Alive
165- } ) ;
170+ server . listen ( common . mustCall ( function ( ) {
171+ var port = server . address ( ) . port ;
172+ var c = net . connect ( { port : port , allowHalfOpen : true } , function ( ) {
173+ c . write ( 'GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n' ) ;
174+ // Keep-Alive
175+ } ) ;
176+ } ) ) ;
166177} ) ;
0 commit comments