mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 23:43:09 +01:00
caee112e52
There is actually no reason to use `assert.doesNotThrow()` in the tests. If a test throws, just let the error bubble up right away instead of first catching it and then rethrowing it. PR-URL: https://github.com/nodejs/node/pull/18669 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
34 lines
820 B
JavaScript
34 lines
820 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const dgram = require('dgram');
|
|
const multicastAddress = '224.0.0.114';
|
|
|
|
const setup = dgram.createSocket.bind(dgram, { type: 'udp4', reuseAddr: true });
|
|
|
|
// addMembership() with valid socket and multicast address should not throw
|
|
{
|
|
const socket = setup();
|
|
socket.addMembership(multicastAddress);
|
|
socket.close();
|
|
}
|
|
|
|
// dropMembership() without previous addMembership should throw
|
|
{
|
|
const socket = setup();
|
|
assert.throws(
|
|
() => { socket.dropMembership(multicastAddress); },
|
|
/^Error: dropMembership EADDRNOTAVAIL$/
|
|
);
|
|
socket.close();
|
|
}
|
|
|
|
// dropMembership() after addMembership() should not throw
|
|
{
|
|
const socket = setup();
|
|
socket.addMembership(multicastAddress);
|
|
socket.dropMembership(multicastAddress);
|
|
socket.close();
|
|
}
|