@@ -59,6 +59,7 @@ function checkDataAndSockets(body) {
5959 assert . strictEqual ( body . toString ( ) , 'hello world' ) ;
6060 assert . strictEqual ( agent . sockets [ name ] . length , 1 ) ;
6161 assert . strictEqual ( agent . freeSockets [ name ] , undefined ) ;
62+ assert . strictEqual ( agent . totalSocketCount , 1 ) ;
6263}
6364
6465function second ( ) {
@@ -73,6 +74,7 @@ function second() {
7374 process . nextTick ( common . mustCall ( ( ) => {
7475 assert . strictEqual ( agent . sockets [ name ] , undefined ) ;
7576 assert . strictEqual ( agent . freeSockets [ name ] . length , 1 ) ;
77+ assert . strictEqual ( agent . totalSocketCount , 1 ) ;
7678 remoteClose ( ) ;
7779 } ) ) ;
7880 } ) ) ;
@@ -91,10 +93,12 @@ function remoteClose() {
9193 process . nextTick ( common . mustCall ( ( ) => {
9294 assert . strictEqual ( agent . sockets [ name ] , undefined ) ;
9395 assert . strictEqual ( agent . freeSockets [ name ] . length , 1 ) ;
96+ assert . strictEqual ( agent . totalSocketCount , 1 ) ;
9497 // Waiting remote server close the socket
9598 setTimeout ( common . mustCall ( ( ) => {
9699 assert . strictEqual ( agent . sockets [ name ] , undefined ) ;
97100 assert . strictEqual ( agent . freeSockets [ name ] , undefined ) ;
101+ assert . strictEqual ( agent . totalSocketCount , 0 ) ;
98102 remoteError ( ) ;
99103 } ) , common . platformTimeout ( 200 ) ) ;
100104 } ) ) ;
@@ -110,10 +114,12 @@ function remoteError() {
110114 assert . strictEqual ( err . message , 'socket hang up' ) ;
111115 assert . strictEqual ( agent . sockets [ name ] . length , 1 ) ;
112116 assert . strictEqual ( agent . freeSockets [ name ] , undefined ) ;
117+ assert . strictEqual ( agent . totalSocketCount , 1 ) ;
113118 // Wait socket 'close' event emit
114119 setTimeout ( common . mustCall ( ( ) => {
115120 assert . strictEqual ( agent . sockets [ name ] , undefined ) ;
116121 assert . strictEqual ( agent . freeSockets [ name ] , undefined ) ;
122+ assert . strictEqual ( agent . totalSocketCount , 0 ) ;
117123 server . close ( ) ;
118124 } ) , common . platformTimeout ( 1 ) ) ;
119125 } ) ) ;
@@ -132,6 +138,7 @@ server.listen(0, common.mustCall(() => {
132138 process . nextTick ( common . mustCall ( ( ) => {
133139 assert . strictEqual ( agent . sockets [ name ] , undefined ) ;
134140 assert . strictEqual ( agent . freeSockets [ name ] . length , 1 ) ;
141+ assert . strictEqual ( agent . totalSocketCount , 1 ) ;
135142 second ( ) ;
136143 } ) ) ;
137144 } ) ) ;
0 commit comments