@@ -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 , 1 ) ;
76
78
remoteClose ( ) ;
77
79
} ) ) ;
78
80
} ) ) ;
@@ -91,10 +93,12 @@ 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 , 1 ) ;
94
97
// Waiting remote server close the socket
95
98
setTimeout ( common . mustCall ( ( ) => {
96
99
assert . strictEqual ( agent . sockets [ name ] , undefined ) ;
97
100
assert . strictEqual ( agent . freeSockets [ name ] , undefined ) ;
101
+ assert . strictEqual ( agent . totalSocketCount , 0 ) ;
98
102
remoteError ( ) ;
99
103
} ) , common . platformTimeout ( 200 ) ) ;
100
104
} ) ) ;
@@ -110,10 +114,12 @@ function remoteError() {
110
114
assert . strictEqual ( err . message , 'socket hang up' ) ;
111
115
assert . strictEqual ( agent . sockets [ name ] . length , 1 ) ;
112
116
assert . strictEqual ( agent . freeSockets [ name ] , undefined ) ;
117
+ assert . strictEqual ( agent . totalSocketCount , 1 ) ;
113
118
// Wait socket 'close' event emit
114
119
setTimeout ( common . mustCall ( ( ) => {
115
120
assert . strictEqual ( agent . sockets [ name ] , undefined ) ;
116
121
assert . strictEqual ( agent . freeSockets [ name ] , undefined ) ;
122
+ assert . strictEqual ( agent . totalSocketCount , 0 ) ;
117
123
server . close ( ) ;
118
124
} ) , common . platformTimeout ( 1 ) ) ;
119
125
} ) ) ;
@@ -132,6 +138,7 @@ server.listen(0, common.mustCall(() => {
132
138
process . nextTick ( common . mustCall ( ( ) => {
133
139
assert . strictEqual ( agent . sockets [ name ] , undefined ) ;
134
140
assert . strictEqual ( agent . freeSockets [ name ] . length , 1 ) ;
141
+ assert . strictEqual ( agent . totalSocketCount , 1 ) ;
135
142
second ( ) ;
136
143
} ) ) ;
137
144
} ) ) ;
0 commit comments