mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
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: https://github.com/nodejs/node/pull/15519 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
1 file changed
+5
-2
@@ -33,11 +33,14 @@ const dgram = require('dgram');
|
||||
socket.bind(0);
|
||||
socket.on('listening', common.mustCall(() => {
|
||||
// Try to set with an invalid interfaceAddress (wrong address class)
|
||||
//
|
||||
// This operation succeeds on some platforms, throws `EINVAL` on some
|
||||
// platforms, and throws `ENOPROTOOPT` on others. This is unpleasant, but
|
||||
// we should at least test for it.
|
||||
try {
|
||||
socket.setMulticastInterface('::');
|
||||
throw new Error('Not detected.');
|
||||
} catch (e) {
|
||||
console.error(`setMulticastInterface: wrong family error is: ${e}`);
|
||||
assert(e.code === 'EINVAL' || e.code === 'ENOPROTOOPT');
|
||||
}
|
||||
|
||||
socket.close();
|
||||
|
||||
Reference in new issue
Block a user