Skip to content
This repository was archived by the owner on Aug 31, 2018. It is now read-only.

Commit 5a19208

Browse files
cjihrigaddaleax
authored andcommitted
test: add missing assertion
This commit adds an assertion to an existing try...catch statement. Unfortunately, assert.throws() cannot be used because the operation succeeds on some platforms, throws EINVAL on some platforms, and throws ENOPROTOOPT on others. PR-URL: nodejs/node#15519 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent e328111 commit 5a19208

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/parallel/test-dgram-multicast-set-interface.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,14 @@ const dgram = require('dgram');
3333
socket.bind(0);
3434
socket.on('listening', common.mustCall(() => {
3535
// Try to set with an invalid interfaceAddress (wrong address class)
36+
//
37+
// This operation succeeds on some platforms, throws `EINVAL` on some
38+
// platforms, and throws `ENOPROTOOPT` on others. This is unpleasant, but
39+
// we should at least test for it.
3640
try {
3741
socket.setMulticastInterface('::');
38-
throw new Error('Not detected.');
3942
} catch (e) {
40-
console.error(`setMulticastInterface: wrong family error is: ${e}`);
43+
assert(e.code === 'EINVAL' || e.code === 'ENOPROTOOPT');
4144
}
4245

4346
socket.close();

0 commit comments

Comments
 (0)