Skip to content

Commit 2a53165

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 db8c92f commit 2a53165

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

+5-2
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)