test: refactor net-connect-handle-econnrefused

- Remove unneeded server
- Use `common.PORT`

PR-URL: https://github.com/nodejs/node/pull/27014
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
pull/27442/head
Luigi Pinca 2019-03-30 15:27:45 +01:00
parent f7afed17b6
commit 66cf4b5d6e
1 changed files with 4 additions and 9 deletions

View File

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