summaryrefslogtreecommitdiff
path: root/test/pummel/test-net-pingpong.js
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2019-01-13 21:01:43 -0800
committerRich Trott <rtrott@gmail.com>2019-01-16 06:49:22 -0800
commit391f839563363690eba9949a7ea3607f50b04d9c (patch)
tree96488bd6a73dc6b8109b35812261cc841104551c /test/pummel/test-net-pingpong.js
parente675d4bd2b9f8d68f8c5deddbfefa92a79edd8a4 (diff)
downloadandroid-node-v8-391f839563363690eba9949a7ea3607f50b04d9c.tar.gz
android-node-v8-391f839563363690eba9949a7ea3607f50b04d9c.tar.bz2
android-node-v8-391f839563363690eba9949a7ea3607f50b04d9c.zip
test: refactor pummel/test-net-pingpong
* Use port 0 instead of `common.PORT`. * Use `//` for comments, capitalize comments, and add punctuation. PR-URL: https://github.com/nodejs/node/pull/25485 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test/pummel/test-net-pingpong.js')
-rw-r--r--test/pummel/test-net-pingpong.js16
1 files changed, 8 insertions, 8 deletions
diff --git a/test/pummel/test-net-pingpong.js b/test/pummel/test-net-pingpong.js
index 29ffd0bdf7..b9507d519d 100644
--- a/test/pummel/test-net-pingpong.js
+++ b/test/pummel/test-net-pingpong.js
@@ -26,7 +26,7 @@ const net = require('net');
let tests_run = 0;
-function pingPongTest(port, host, on_complete) {
+function pingPongTest(host, on_complete) {
const N = 1000;
let count = 0;
let sent_final_ping = false;
@@ -69,8 +69,8 @@ function pingPongTest(port, host, on_complete) {
});
});
- server.listen(port, host, function() {
- const client = net.createConnection(port, host);
+ server.listen(0, host, function() {
+ const client = net.createConnection(server.address().port, host);
client.setEncoding('utf8');
@@ -110,12 +110,12 @@ function pingPongTest(port, host, on_complete) {
});
}
-/* All are run at once, so run on different ports */
-pingPongTest(common.PORT, 'localhost');
-pingPongTest(common.PORT + 1, null);
+// All are run at once and will run on different ports.
+pingPongTest('localhost');
+pingPongTest(null);
-// This IPv6 isn't working on Solaris
-if (!common.isSunOS) pingPongTest(common.PORT + 2, '::1');
+// This IPv6 isn't working on Solaris.
+if (!common.isSunOS) pingPongTest('::1');
process.on('exit', function() {
assert.strictEqual(tests_run, common.isSunOS ? 2 : 3);