@@ -59,6 +59,7 @@ function checkDataAndSockets(body) {
59
59
assert . strictEqual ( body . toString ( ) , 'hello world' ) ;
60
60
assert . strictEqual ( agent . sockets [ name ] . length , 1 ) ;
61
61
assert . strictEqual ( agent . freeSockets [ name ] , undefined ) ;
62
+ assert . strictEqual ( agent . totalSocketCount , 1 ) ;
62
63
}
63
64
64
65
function second ( ) {
@@ -73,6 +74,7 @@ function second() {
73
74
process . nextTick ( common . mustCall ( ( ) => {
74
75
assert . strictEqual ( agent . sockets [ name ] , undefined ) ;
75
76
assert . strictEqual ( agent . freeSockets [ name ] . length , 1 ) ;
77
+ assert . strictEqual ( agent . totalSocketCount , 0 ) ;
76
78
remoteClose ( ) ;
77
79
} ) ) ;
78
80
} ) ) ;
@@ -91,6 +93,7 @@ function remoteClose() {
91
93
process . nextTick ( common . mustCall ( ( ) => {
92
94
assert . strictEqual ( agent . sockets [ name ] , undefined ) ;
93
95
assert . strictEqual ( agent . freeSockets [ name ] . length , 1 ) ;
96
+ assert . strictEqual ( agent . totalSocketCount , 0 ) ;
94
97
// Waiting remote server close the socket
95
98
setTimeout ( common . mustCall ( ( ) => {
96
99
assert . strictEqual ( agent . sockets [ name ] , undefined ) ;
@@ -110,10 +113,12 @@ function remoteError() {
110
113
assert . strictEqual ( err . message , 'socket hang up' ) ;
111
114
assert . strictEqual ( agent . sockets [ name ] . length , 1 ) ;
112
115
assert . strictEqual ( agent . freeSockets [ name ] , undefined ) ;
116
+ assert . strictEqual ( agent . totalSocketCount , 0 ) ;
113
117
// Wait socket 'close' event emit
114
118
setTimeout ( common . mustCall ( ( ) => {
115
119
assert . strictEqual ( agent . sockets [ name ] , undefined ) ;
116
120
assert . strictEqual ( agent . freeSockets [ name ] , undefined ) ;
121
+ assert . strictEqual ( agent . totalSocketCount , - 1 ) ;
117
122
server . close ( ) ;
118
123
} ) , common . platformTimeout ( 1 ) ) ;
119
124
} ) ) ;
@@ -132,6 +137,7 @@ server.listen(0, common.mustCall(() => {
132
137
process . nextTick ( common . mustCall ( ( ) => {
133
138
assert . strictEqual ( agent . sockets [ name ] , undefined ) ;
134
139
assert . strictEqual ( agent . freeSockets [ name ] . length , 1 ) ;
140
+ assert . strictEqual ( agent . totalSocketCount , 0 ) ;
135
141
second ( ) ;
136
142
} ) ) ;
137
143
} ) ) ;
0 commit comments