Skip to content

Commit

Permalink
test: update test-cluster-shared-handle-bind-error
Browse files Browse the repository at this point in the history
- Remove assignment of this to variable.
- Add common.mustCall() as needed.
- Move from var to const.

PR-URL: #10547
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information
cjihrig authored and MylesBorins committed Feb 1, 2017
1 parent f5e54f5 commit 37a3622
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions test/parallel/test-cluster-shared-handle-bind-error.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
'use strict';
var common = require('../common');
var assert = require('assert');
var cluster = require('cluster');
var net = require('net');
const common = require('../common');
const assert = require('assert');
const cluster = require('cluster');
const net = require('net');

if (cluster.isMaster) {
// Master opens and binds the socket and shares it with the worker.
cluster.schedulingPolicy = cluster.SCHED_NONE;
// Hog the TCP port so that when the worker tries to bind, it'll fail.
net.createServer(common.fail).listen(common.PORT, function() {
var server = this;
var worker = cluster.fork();
worker.on('exit', common.mustCall(function(exitCode) {
const server = net.createServer(common.fail);

server.listen(common.PORT, common.mustCall(() => {
const worker = cluster.fork();
worker.on('exit', common.mustCall((exitCode) => {
assert.strictEqual(exitCode, 0);
server.close();
}));
});
}));
} else {
var s = net.createServer(common.fail);
const s = net.createServer(common.fail);
s.listen(common.PORT, common.fail.bind(null, 'listen should have failed'));
s.on('error', common.mustCall(function(err) {
s.on('error', common.mustCall((err) => {
assert.strictEqual(err.code, 'EADDRINUSE');
process.disconnect();
}));
Expand Down

0 comments on commit 37a3622

Please sign in to comment.