mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 07:27:22 +01:00
66369d05a2
Update test to match current test guidelines and use common.mustCall instead of unref'd timer. PR-URL: https://github.com/nodejs/node/pull/8703 Fixes: https://github.com/nodejs/node/issues/8700 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
28 lines
675 B
JavaScript
28 lines
675 B
JavaScript
'use strict';
|
|
// test-cluster-worker-init.js
|
|
// verifies that, when a child process is forked, the cluster.worker
|
|
// object can receive messages as expected
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const cluster = require('cluster');
|
|
const msg = 'foo';
|
|
|
|
if (cluster.isMaster) {
|
|
const worker = cluster.fork();
|
|
|
|
worker.on('message', common.mustCall((message) => {
|
|
assert.strictEqual(message, true, 'did not receive expected message');
|
|
worker.disconnect();
|
|
}));
|
|
|
|
worker.on('online', () => {
|
|
worker.send(msg);
|
|
});
|
|
} else {
|
|
// GH #7998
|
|
cluster.worker.on('message', (message) => {
|
|
process.send(message === msg);
|
|
});
|
|
}
|