Skip to content
Closed
Changes from all commits
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
26 changes: 14 additions & 12 deletions test/sequential/test-net-listen-shared-ports.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ const net = require('net');
if (cluster.isMaster) {
const worker1 = cluster.fork();

worker1.on('message', function(msg) {
worker1.on('message', common.mustCall(function(msg) {
assert.strictEqual(msg, 'success');
const worker2 = cluster.fork();

worker2.on('message', function(msg) {
worker2.on('message', common.mustCall(function(msg) {
assert.strictEqual(msg, 'server2:EADDRINUSE');
worker1.kill();
worker2.kill();
});
});
}));
}));
} else {
const server1 = net.createServer(common.noop);
const server2 = net.createServer(common.noop);
const server1 = net.createServer(common.mustNotCall());
const server2 = net.createServer(common.mustNotCall());

server1.on('error', function(err) {
// no errors expected
Expand All @@ -56,10 +56,12 @@ if (cluster.isMaster) {
host: 'localhost',
port: common.PORT,
exclusive: false
}, function() {
server2.listen({port: common.PORT + 1, exclusive: true}, function() {
// the first worker should succeed
process.send('success');
});
});
}, common.mustCall(function() {
server2.listen({port: common.PORT + 1, exclusive: true},
common.mustCall(function() {
// the first worker should succeed
process.send('success');
})
);
}));
}