Skip to content

Commit c5e3353

Browse files
committed
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: #15519 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent a9f5084 commit c5e3353

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)