Skip to content

Commit 6347940

Browse files
Trottaddaleax
authored andcommitted
test: refactor pummel/test-net-pingpong
* Use port 0 instead of `common.PORT`. * Use `//` for comments, capitalize comments, and add punctuation. PR-URL: #25485 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 307da2d commit 6347940

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

test/pummel/test-net-pingpong.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const net = require('net');
2626

2727
let tests_run = 0;
2828

29-
function pingPongTest(port, host, on_complete) {
29+
function pingPongTest(host, on_complete) {
3030
const N = 1000;
3131
let count = 0;
3232
let sent_final_ping = false;
@@ -69,8 +69,8 @@ function pingPongTest(port, host, on_complete) {
6969
});
7070
});
7171

72-
server.listen(port, host, function() {
73-
const client = net.createConnection(port, host);
72+
server.listen(0, host, function() {
73+
const client = net.createConnection(server.address().port, host);
7474

7575
client.setEncoding('utf8');
7676

@@ -110,12 +110,12 @@ function pingPongTest(port, host, on_complete) {
110110
});
111111
}
112112

113-
/* All are run at once, so run on different ports */
114-
pingPongTest(common.PORT, 'localhost');
115-
pingPongTest(common.PORT + 1, null);
113+
// All are run at once and will run on different ports.
114+
pingPongTest('localhost');
115+
pingPongTest(null);
116116

117-
// This IPv6 isn't working on Solaris
118-
if (!common.isSunOS) pingPongTest(common.PORT + 2, '::1');
117+
// This IPv6 isn't working on Solaris.
118+
if (!common.isSunOS) pingPongTest('::1');
119119

120120
process.on('exit', function() {
121121
assert.strictEqual(tests_run, common.isSunOS ? 2 : 3);

0 commit comments

Comments
 (0)