()
| 82 | } |
| 83 | |
| 84 | function remoteClose() { |
| 85 | // Mock remote server close the socket |
| 86 | const req = get('/remote_close', common.mustCall((res) => { |
| 87 | assert.strictEqual(req.reusedSocket, true); |
| 88 | assert.strictEqual(res.statusCode, 200); |
| 89 | res.on('data', checkDataAndSockets); |
| 90 | res.on('end', common.mustCall(() => { |
| 91 | assert.strictEqual(agent.sockets[name].length, 1); |
| 92 | assert.strictEqual(agent.freeSockets[name], undefined); |
| 93 | process.nextTick(common.mustCall(() => { |
| 94 | assert.strictEqual(agent.sockets[name], undefined); |
| 95 | assert.strictEqual(agent.freeSockets[name].length, 1); |
| 96 | assert.strictEqual(agent.totalSocketCount, 1); |
| 97 | // Waiting remote server close the socket |
| 98 | setTimeout(common.mustCall(() => { |
| 99 | assert.strictEqual(agent.sockets[name], undefined); |
| 100 | assert.strictEqual(agent.freeSockets[name], undefined); |
| 101 | assert.strictEqual(agent.totalSocketCount, 0); |
| 102 | remoteError(); |
| 103 | }), common.platformTimeout(200)); |
| 104 | })); |
| 105 | })); |
| 106 | })); |
| 107 | } |
| 108 | |
| 109 | function remoteError() { |
| 110 | // Remote server will destroy the socket |
no test coverage detected