test: ensure assertions are reachable in `test/internet` · nodejs/node@eca6227
@@ -84,7 +84,7 @@ if (process.argv[2] !== 'child') {
8484worker.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') {
108108109109process.exit(1);
110110}
111-});
111+}));
112112113-worker.on('message', (msg) => {
113+worker.on('message', common.mustCallAtLeast((msg) => {
114114if (msg.listening) {
115115listening += 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)) {
138138const worker = workers[pid];
139139140140let count = 0;
@@ -153,14 +153,14 @@ if (process.argv[2] !== 'child') {
153153count);
154154155155assert.strictEqual(count, messages.length);
156-});
156+}
157157158158clearTimeout(timer);
159159console.error('[PARENT] Success');
160160killSubprocesses(workers);
161161}
162162}
163-});
163+}));
164164})(x);
165165}
166166@@ -196,14 +196,13 @@ if (process.argv[2] !== 'child') {
196196buf.length,
197197common.PORT,
198198LOCAL_BROADCAST_HOST,
199-(err) => {
200-assert.ifError(err);
199+common.mustSucceed(() => {
201200console.error('[PARENT] sent %s to %s:%s',
202201util.inspect(buf.toString()),
203202LOCAL_BROADCAST_HOST, common.PORT);
204203205204process.nextTick(sendSocket.sendNext);
206-},
205+}),
207206);
208207};
209208