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

Commit

Permalink
test: add missing assertion
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
cjihrig authored and addaleax committed Dec 7, 2017
1 parent e328111 commit 5a19208
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/parallel/test-dgram-multicast-set-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 5a19208

Please sign in to comment.