11'use strict' ;
2- var common = require ( '../common' ) ;
3- var assert = require ( 'assert' ) ;
2+ const common = require ( '../common' ) ;
3+ const assert = require ( 'assert' ) ;
44
5- var net = require ( 'net' ) ;
5+ const net = require ( 'net' ) ;
66
7- // This test creates 200 connections to a server and sets the server's
8- // maxConnections property to 100 . The first 100 connections make it through
9- // and the last 100 connections are rejected.
7+ // This test creates 20 connections to a server and sets the server's
8+ // maxConnections property to 10 . The first 10 connections make it through
9+ // and the last 10 connections are rejected.
1010
11- var N = 200 ;
11+ const N = 20 ;
1212var count = 0 ;
1313var closes = 0 ;
14- var waits = [ ] ;
14+ const waits = [ ] ;
1515
16- var server = net . createServer ( function ( connection ) {
16+ const server = net . createServer ( function ( connection ) {
1717 console . error ( 'connect %d' , count ++ ) ;
1818 connection . write ( 'hello' ) ;
1919 waits . push ( function ( ) { connection . end ( ) ; } ) ;
@@ -29,7 +29,7 @@ console.error('server.maxConnections = %d', server.maxConnections);
2929
3030
3131function makeConnection ( index ) {
32- var c = net . createConnection ( server . address ( ) . port ) ;
32+ const c = net . createConnection ( server . address ( ) . port ) ;
3333 var gotData = false ;
3434
3535 c . on ( 'connect' , function ( ) {
@@ -42,10 +42,10 @@ function makeConnection(index) {
4242 closes ++ ;
4343
4444 if ( closes < N / 2 ) {
45- assert . ok ( server . maxConnections <= index ,
46- index +
47- ' was one of the first closed connections ' +
48- 'but shouldnt have been' ) ;
45+ assert . ok (
46+ server . maxConnections <= index ,
47+ ` ${ index } should not have been one of the first closed connections`
48+ ) ;
4949 }
5050
5151 if ( closes === N / 2 ) {
@@ -58,11 +58,11 @@ function makeConnection(index) {
5858 }
5959
6060 if ( index < server . maxConnections ) {
61- assert . equal ( true , gotData ,
62- index + ' didn\ 't get data, but should have' ) ;
61+ assert . strictEqual ( true , gotData ,
62+ ` ${ index } didn't get data, but should have` ) ;
6363 } else {
64- assert . equal ( false , gotData ,
65- index + ' got data, but shouldn\ 't have' ) ;
64+ assert . strictEqual ( false , gotData ,
65+ ` ${ index } got data, but shouldn't have` ) ;
6666 }
6767 } ) ;
6868 } ) ;
@@ -86,5 +86,5 @@ function makeConnection(index) {
8686
8787
8888process . on ( 'exit' , function ( ) {
89- assert . equal ( N , closes ) ;
89+ assert . strictEqual ( N , closes ) ;
9090} ) ;
0 commit comments