Skip to content
Permalink
Browse files

test: refactor test-dgram-multicast-set-interface-lo.js

Convert functions to arrow functions. Remove unused param('signal') from
function.

PR-URL: #30536
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information...
Taylor Gagne authored and Trott committed Nov 18, 2019
1 parent 64ee64d commit a18ec07406170cdfd36bebe30f4eeb97bb1828ba
Showing with 17 additions and 16 deletions.
  1. +17 −16 test/internet/test-dgram-multicast-set-interface-lo.js
@@ -83,8 +83,14 @@ if (process.argv[2] !== 'child') {
let i = 0;
let done = 0;
let timer = null;

const killSubprocesses = (subprocesses) => {
for (const i in subprocesses)
subprocesses[i].kill();
};

// Exit the test if it doesn't succeed within the TIMEOUT.
timer = setTimeout(function() {
timer = setTimeout(() => {
console.error('[PARENT] Responses were not received within %d ms.',
TIMEOUT);
console.error('[PARENT] Skip');
@@ -115,7 +121,7 @@ if (process.argv[2] !== 'child') {
worker.messagesNeeded = messagesNeeded;

// Handle the death of workers.
worker.on('exit', function(code, signal) {
worker.on('exit', (code) => {
// Don't consider this a true death if the worker has finished
// successfully or if the exit code is 0.
if (worker.isDone || code === 0) {
@@ -138,7 +144,7 @@ if (process.argv[2] !== 'child') {
}
});

worker.on('message', function(msg) {
worker.on('message', (msg) => {
if (msg.listening) {
listening += 1;

@@ -162,12 +168,12 @@ if (process.argv[2] !== 'child') {
'required number of ' +
'messages. Will now compare.');

Object.keys(workers).forEach(function(pid) {
Object.keys(workers).forEach((pid) => {
const worker = workers[pid];

let count = 0;

worker.messagesReceived.forEach(function(buf) {
worker.messagesReceived.forEach((buf) => {
for (let i = 0; i < worker.messagesNeeded.length; ++i) {
if (buf.toString() === worker.messagesNeeded[i]) {
count++;
@@ -201,15 +207,15 @@ if (process.argv[2] !== 'child') {
// Don't bind the address explicitly when sending and start with
// the OSes default multicast interface selection.
sendSocket.bind(common.PORT, ANY[FAM]);
sendSocket.on('listening', function() {
sendSocket.on('listening', () => {
console.error(`outgoing iface ${interfaceAddress}`);
});

sendSocket.on('close', function() {
sendSocket.on('close', () => {
console.error('[PARENT] sendSocket closed');
});

sendSocket.sendNext = function() {
sendSocket.sendNext = () => {
const msg = messages[i++];

if (!msg) {
@@ -228,7 +234,7 @@ if (process.argv[2] !== 'child') {
buf.length,
PORTS[msg.mcast],
msg.mcast,
function(err) {
(err) => {
assert.ifError(err);
console.error('[PARENT] sent %s to %s:%s',
util.inspect(buf.toString()),
@@ -238,11 +244,6 @@ if (process.argv[2] !== 'child') {
}
);
};

function killSubprocesses(subprocesses) {
for (const i in subprocesses)
subprocesses[i].kill();
}
}

if (process.argv[2] === 'child') {
@@ -258,7 +259,7 @@ if (process.argv[2] === 'child') {
reuseAddr: true
});

listenSocket.on('message', function(buf, rinfo) {
listenSocket.on('message', (buf, rinfo) => {
// Examine udp messages only when they were sent by the parent.
if (!buf.toString().startsWith(SESSION)) return;

@@ -280,7 +281,7 @@ if (process.argv[2] === 'child') {
});


listenSocket.on('listening', function() {
listenSocket.on('listening', () => {
listenSocket.addMembership(MULTICAST, IFACE);
process.send({ listening: true });
});

0 comments on commit a18ec07

Please sign in to comment.
You can’t perform that action at this time.