Skip to content

Commit 7e5ed8b

Browse files
Trottaddaleax
authored andcommitted
test: track callback invocations
Use `common.mustCall()` and `common.mustNotCall()` to check that callbacks are invoked the expected number of times in test-net-listen-shared-ports. PR-URL: #13010 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
1 parent 28ddac2 commit 7e5ed8b

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

test/sequential/test-net-listen-shared-ports.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ const net = require('net');
2828
if (cluster.isMaster) {
2929
const worker1 = cluster.fork();
3030

31-
worker1.on('message', function(msg) {
31+
worker1.on('message', common.mustCall(function(msg) {
3232
assert.strictEqual(msg, 'success');
3333
const worker2 = cluster.fork();
3434

35-
worker2.on('message', function(msg) {
35+
worker2.on('message', common.mustCall(function(msg) {
3636
assert.strictEqual(msg, 'server2:EADDRINUSE');
3737
worker1.kill();
3838
worker2.kill();
39-
});
40-
});
39+
}));
40+
}));
4141
} else {
42-
const server1 = net.createServer(common.noop);
43-
const server2 = net.createServer(common.noop);
42+
const server1 = net.createServer(common.mustNotCall());
43+
const server2 = net.createServer(common.mustNotCall());
4444

4545
server1.on('error', function(err) {
4646
// no errors expected
@@ -56,10 +56,12 @@ if (cluster.isMaster) {
5656
host: 'localhost',
5757
port: common.PORT,
5858
exclusive: false
59-
}, function() {
60-
server2.listen({port: common.PORT + 1, exclusive: true}, function() {
61-
// the first worker should succeed
62-
process.send('success');
63-
});
64-
});
59+
}, common.mustCall(function() {
60+
server2.listen({port: common.PORT + 1, exclusive: true},
61+
common.mustCall(function() {
62+
// the first worker should succeed
63+
process.send('success');
64+
})
65+
);
66+
}));
6567
}

0 commit comments

Comments
 (0)