summaryrefslogtreecommitdiff
path: root/test/parallel/test-cluster-listening-port.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-cluster-listening-port.js')
-rw-r--r--test/parallel/test-cluster-listening-port.js11
1 files changed, 3 insertions, 8 deletions
diff --git a/test/parallel/test-cluster-listening-port.js b/test/parallel/test-cluster-listening-port.js
index 810364a926..b0fbf94990 100644
--- a/test/parallel/test-cluster-listening-port.js
+++ b/test/parallel/test-cluster-listening-port.js
@@ -5,20 +5,15 @@ var cluster = require('cluster');
var net = require('net');
if (cluster.isMaster) {
- var port = null;
cluster.fork();
- cluster.on('listening', function(worker, address) {
- port = address.port;
+ cluster.on('listening', common.mustCall(function(worker, address) {
+ const port = address.port;
// ensure that the port is not 0 or null
assert(port);
// ensure that the port is numerical
assert.strictEqual(typeof port, 'number');
worker.kill();
- });
- process.on('exit', function() {
- // ensure that the 'listening' handler has been called
- assert(port);
- });
+ }));
} else {
net.createServer(common.fail).listen(0);
}