@@ -36,16 +36,6 @@ const options = {
3636 cert : fs . readFileSync ( common . fixturesDir + '/keys/agent1-cert.pem' )
3737} ;
3838
39- const tests = 2 ;
40- let successful = 0 ;
41-
42- const testSucceeded = function ( ) {
43- successful = successful + 1 ;
44- if ( successful === tests ) {
45- server . close ( ) ;
46- }
47- } ;
48-
4939const body = 'hello world\n' ;
5040
5141const serverCallback = common . mustCall ( function ( req , res ) {
@@ -55,7 +45,7 @@ const serverCallback = common.mustCall(function(req, res) {
5545
5646const server = https . createServer ( options , serverCallback ) ;
5747
58- server . listen ( 0 , function ( ) {
48+ server . listen ( 0 , function ( ) {
5949 // Do a request ignoring the unauthorized server certs
6050 const noCertCheckOptions = {
6151 hostname : '127.0.0.1' ,
@@ -66,16 +56,15 @@ server.listen(0, function() {
6656 } ;
6757 noCertCheckOptions . Agent = new https . Agent ( noCertCheckOptions ) ;
6858
69- const req = https . request ( noCertCheckOptions , function ( res ) {
59+ const req = https . request ( noCertCheckOptions , function ( res ) {
7060 let responseBody = '' ;
7161 res . on ( 'data' , function ( d ) {
7262 responseBody = responseBody + d ;
7363 } ) ;
7464
75- res . on ( 'end' , function ( ) {
65+ res . on ( 'end' , common . mustCall ( ( ) => {
7666 assert . strictEqual ( responseBody , body ) ;
77- testSucceeded ( ) ;
78- } ) ;
67+ } ) ) ;
7968 } ) ;
8069 req . end ( ) ;
8170
@@ -108,6 +97,6 @@ server.listen(0, function() {
10897 } ) ;
10998} ) ;
11099
111- process . on ( 'exit' , function ( ) {
112- assert . strictEqual ( successful , tests ) ;
113- } ) ;
100+ function testSucceeded ( ) {
101+ server . close ( ) ;
102+ } ;
0 commit comments