summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTaylor Gagne <tgagne@netsurion.com>2019-11-18 15:13:54 -0500
committerRich Trott <rtrott@gmail.com>2019-11-21 21:52:56 -0800
commita18ec07406170cdfd36bebe30f4eeb97bb1828ba (patch)
tree40af9345c40b258d4f3126db4734c005516a12e5 /test
parent64ee64d3afc837350ee39058cef9179e92f3554c (diff)
downloadandroid-node-v8-a18ec07406170cdfd36bebe30f4eeb97bb1828ba.tar.gz
android-node-v8-a18ec07406170cdfd36bebe30f4eeb97bb1828ba.tar.bz2
android-node-v8-a18ec07406170cdfd36bebe30f4eeb97bb1828ba.zip
test: refactor test-dgram-multicast-set-interface-lo.js
Convert functions to arrow functions. Remove unused param('signal') from function. PR-URL: https://github.com/nodejs/node/pull/30536 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test')
-rw-r--r--test/internet/test-dgram-multicast-set-interface-lo.js33
1 files changed, 17 insertions, 16 deletions
diff --git a/test/internet/test-dgram-multicast-set-interface-lo.js b/test/internet/test-dgram-multicast-set-interface-lo.js
index 73ab31884d..e06969b7b2 100644
--- a/test/internet/test-dgram-multicast-set-interface-lo.js
+++ b/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 });
});