test: ensure assertions are reachable in `test/internet` · nodejs/node@eca6227

@@ -84,7 +84,7 @@ if (process.argv[2] !== 'child') {

8484

worker.messagesReceived = [];

85858686

// Handle the death of workers

87-

worker.on('exit', (code, signal) => {

87+

worker.on('exit', common.mustCall((code, signal) => {

8888

// Don't consider this the true death if the worker

8989

// has finished successfully

9090

// or if the exit code is 0

@@ -108,9 +108,9 @@ if (process.argv[2] !== 'child') {

108108109109

process.exit(1);

110110

}

111-

});

111+

}));

112112113-

worker.on('message', (msg) => {

113+

worker.on('message', common.mustCallAtLeast((msg) => {

114114

if (msg.listening) {

115115

listening += 1;

116116

@@ -134,7 +134,7 @@ if (process.argv[2] !== 'child') {

134134

'required number of ' +

135135

'messages. Will now compare.');

136136137-

Object.keys(workers).forEach((pid) => {

137+

for (const pid of Object.keys(workers)) {

138138

const worker = workers[pid];

139139140140

let count = 0;

@@ -153,14 +153,14 @@ if (process.argv[2] !== 'child') {

153153

count);

154154155155

assert.strictEqual(count, messages.length);

156-

});

156+

}

157157158158

clearTimeout(timer);

159159

console.error('[PARENT] Success');

160160

killSubprocesses(workers);

161161

}

162162

}

163-

});

163+

}));

164164

})(x);

165165

}

166166

@@ -196,14 +196,13 @@ if (process.argv[2] !== 'child') {

196196

buf.length,

197197

common.PORT,

198198

LOCAL_BROADCAST_HOST,

199-

(err) => {

200-

assert.ifError(err);

199+

common.mustSucceed(() => {

201200

console.error('[PARENT] sent %s to %s:%s',

202201

util.inspect(buf.toString()),

203202

LOCAL_BROADCAST_HOST, common.PORT);

204203205204

process.nextTick(sendSocket.sendNext);

206-

},

205+

}),

207206

);

208207

};

209208