diff --git a/test/parallel/test-cluster-worker-init.js b/test/parallel/test-cluster-worker-init.js index 41f73e1255..3b82866d1b 100644 --- a/test/parallel/test-cluster-worker-init.js +++ b/test/parallel/test-cluster-worker-init.js @@ -3,30 +3,25 @@ // verifies that, when a child process is forked, the cluster.worker // object can receive messages as expected -require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); -var msg = 'foo'; +const common = require('../common'); +const assert = require('assert'); +const cluster = require('cluster'); +const msg = 'foo'; if (cluster.isMaster) { - var worker = cluster.fork(); - var timer = setTimeout(function() { - assert(false, 'message not received'); - }, 5000); + const worker = cluster.fork(); - timer.unref(); - - worker.on('message', function(message) { - assert(message, 'did not receive expected message'); + worker.on('message', common.mustCall((message) => { + assert.strictEqual(message, true, 'did not receive expected message'); worker.disconnect(); - }); + })); - worker.on('online', function() { + worker.on('online', () => { worker.send(msg); }); } else { // GH #7998 - cluster.worker.on('message', function(message) { + cluster.worker.on('message', (message) => { process.send(message === msg); }); }