Skip to content

Commit

Permalink
test: remove common.PORT from test-net-timeout
Browse files Browse the repository at this point in the history
Switch test-net-timeout from common.PORT to a port assigned by the
operating system.

PR-URL: #31749
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
Trott authored and codebytere committed Mar 30, 2020
1 parent 17882ac commit d172cc1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/pummel/test-net-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
const common = require('../common');
require('../common');
const assert = require('assert');
const net = require('net');

Expand Down Expand Up @@ -54,10 +54,11 @@ const echo_server = net.createServer((socket) => {
});
});

echo_server.listen(common.PORT, () => {
console.log(`server listening at ${common.PORT}`);
echo_server.listen(0, () => {
const port = echo_server.address().port;
console.log(`server listening at ${port}`);

const client = net.createConnection(common.PORT);
const client = net.createConnection(port);
client.setEncoding('UTF8');
client.setTimeout(0); // Disable the timeout for client
client.on('connect', () => {
Expand Down

0 comments on commit d172cc1

Please sign in to comment.