Skip to content

Commit

Permalink
test: remove common.PORT from test-net-throttle
Browse files Browse the repository at this point in the history
Switch test-net-throttle 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 Feb 27, 2020
1 parent 724bf31 commit e76ac1d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/pummel/test-net-throttle.js
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 All @@ -32,8 +32,6 @@ let npauses = 0;
console.log('build big string');
const body = 'C'.repeat(N);

console.log(`start server on port ${common.PORT}`);

const server = net.createServer((connection) => {
connection.write(body.slice(0, part_N));
connection.write(body.slice(part_N, 2 * part_N));
Expand All @@ -44,9 +42,11 @@ const server = net.createServer((connection) => {
connection.end();
});

server.listen(common.PORT, () => {
server.listen(0, () => {
const port = server.address().port;
console.log(`server started on port ${port}`);
let paused = false;
const client = net.createConnection(common.PORT);
const client = net.createConnection(port);
client.setEncoding('ascii');
client.on('data', (d) => {
chars_recved += d.length;
Expand Down

0 comments on commit e76ac1d

Please sign in to comment.