test: try to connect after server was closed

PR-URL: https://github.com/nodejs/node/pull/18257
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
pull/18787/merge
Leko 2018-01-20 00:26:50 +09:00 committed by Ruben Bridgewater
parent b74a6da5d0
commit befe675af8
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
1 changed files with 6 additions and 7 deletions

View File

@ -27,11 +27,10 @@ const assert = require('assert');
const server = net.createServer();
server.listen(0);
const port = server.address().port;
const c = net.createConnection(port);
c.on('connect', common.mustNotCall());
c.on('error', common.mustCall((e) => {
assert.strictEqual('ECONNREFUSED', e.code);
server.close(common.mustCall(() => {
const c = net.createConnection(port);
c.on('connect', common.mustNotCall());
c.on('error', common.mustCall((e) => {
assert.strictEqual('ECONNREFUSED', e.code);
}));
}));
server.close();