Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: wrap functions containing assertions inside a common.mustCall
  • Loading branch information
sagirk committed Nov 22, 2018
commit 0d08ce2bf4df1f8eabcd8ae7117a80e168ae1f8f
10 changes: 5 additions & 5 deletions test/parallel/test-cluster-send-deadlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
// Testing mutual send of handles: from master to worker, and from worker to
// master.

require('../common');
const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');
const net = require('net');

if (cluster.isMaster) {
const worker = cluster.fork();
worker.on('exit', (code, signal) => {
worker.on('exit', common.mustCall((code, signal) => {
assert.strictEqual(code, 0, `Worker exited with an error code: ${code}`);
assert(!signal, `Worker exited by a signal: ${signal}`);
server.close();
});
}));

const server = net.createServer((socket) => {
worker.send('handle', socket);
Expand All @@ -44,7 +44,7 @@ if (cluster.isMaster) {
worker.send({ message: 'listen', port: server.address().port });
});
} else {
process.on('message', (msg, handle) => {
process.on('message', common.mustCall((msg, handle) => {
if (msg.message && msg.message === 'listen') {
assert(msg.port);
const client1 = net.connect({
Expand All @@ -69,5 +69,5 @@ if (cluster.isMaster) {
} else {
process.send('reply', handle);
}
});
}));
}