mirror of
https://github.com/nodejs/node.git
synced 2026-11-29 14:27:57 -05:00
dgram: test to add and to drop specific membership
Test of addSourceSpecificMembership and dropSourceSpecificMembership for correct arguments with sourceAddress, groupAddress. PR-URL: https://github.com/nodejs/node/pull/31047 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
1 parent
ffe92267fc
commit
25d96ecd4b
2 files changed
+80
-8
No files matched your search
+4
-8
@@ -856,13 +856,11 @@ Socket.prototype.addSourceSpecificMembership = function(sourceAddress,
|
||||
healthCheck(this);
|
||||
|
||||
if (typeof sourceAddress !== 'string') {
|
||||
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'sourceAddress',
|
||||
'string');
|
||||
throw new ERR_INVALID_ARG_TYPE('sourceAddress', 'string', sourceAddress);
|
||||
}
|
||||
|
||||
if (typeof groupAddress !== 'string') {
|
||||
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'groupAddress',
|
||||
'string');
|
||||
throw new ERR_INVALID_ARG_TYPE('groupAddress', 'string', groupAddress);
|
||||
}
|
||||
|
||||
const err =
|
||||
@@ -881,13 +879,11 @@ Socket.prototype.dropSourceSpecificMembership = function(sourceAddress,
|
||||
healthCheck(this);
|
||||
|
||||
if (typeof sourceAddress !== 'string') {
|
||||
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'sourceAddress',
|
||||
'string');
|
||||
throw new ERR_INVALID_ARG_TYPE('sourceAddress', 'string', sourceAddress);
|
||||
}
|
||||
|
||||
if (typeof groupAddress !== 'string') {
|
||||
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'groupAddress',
|
||||
'string');
|
||||
throw new ERR_INVALID_ARG_TYPE('groupAddress', 'string', groupAddress);
|
||||
}
|
||||
|
||||
const err =
|
||||
|
||||
@@ -76,3 +76,79 @@ const setup = dgram.createSocket.bind(dgram, { type: 'udp4', reuseAddr: true });
|
||||
/^Error: dropMembership EINVAL$/);
|
||||
socket.close();
|
||||
}
|
||||
|
||||
// addSourceSpecificMembership with invalid sourceAddress should throw
|
||||
{
|
||||
const socket = setup();
|
||||
assert.throws(() => {
|
||||
socket.addSourceSpecificMembership(0, multicastAddress);
|
||||
}, {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
message: 'The "sourceAddress" argument must be of type string. ' +
|
||||
'Received type number (0)'
|
||||
});
|
||||
socket.close();
|
||||
}
|
||||
|
||||
// addSourceSpecificMembership with invalid sourceAddress should throw
|
||||
{
|
||||
const socket = setup();
|
||||
assert.throws(() => {
|
||||
socket.addSourceSpecificMembership(multicastAddress, 0);
|
||||
}, {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
message: 'The "groupAddress" argument must be of type string. ' +
|
||||
'Received type number (0)'
|
||||
});
|
||||
socket.close();
|
||||
}
|
||||
|
||||
// addSourceSpecificMembership with invalid groupAddress should throw
|
||||
{
|
||||
const socket = setup();
|
||||
assert.throws(() => {
|
||||
socket.addSourceSpecificMembership(multicastAddress, '0');
|
||||
}, {
|
||||
code: 'EINVAL',
|
||||
message: 'addSourceSpecificMembership EINVAL'
|
||||
});
|
||||
socket.close();
|
||||
}
|
||||
|
||||
// dropSourceSpecificMembership with invalid sourceAddress should throw
|
||||
{
|
||||
const socket = setup();
|
||||
assert.throws(() => {
|
||||
socket.dropSourceSpecificMembership(0, multicastAddress);
|
||||
}, {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
message: 'The "sourceAddress" argument must be of type string. ' +
|
||||
'Received type number (0)'
|
||||
});
|
||||
socket.close();
|
||||
}
|
||||
|
||||
// dropSourceSpecificMembership with invalid groupAddress should throw
|
||||
{
|
||||
const socket = setup();
|
||||
assert.throws(() => {
|
||||
socket.dropSourceSpecificMembership(multicastAddress, 0);
|
||||
}, {
|
||||
code: 'ERR_INVALID_ARG_TYPE',
|
||||
message: 'The "groupAddress" argument must be of type string. ' +
|
||||
'Received type number (0)'
|
||||
});
|
||||
socket.close();
|
||||
}
|
||||
|
||||
// dropSourceSpecificMembership with invalid UDP should throw
|
||||
{
|
||||
const socket = setup();
|
||||
assert.throws(() => {
|
||||
socket.dropSourceSpecificMembership(multicastAddress, '0');
|
||||
}, {
|
||||
code: 'EINVAL',
|
||||
message: 'dropSourceSpecificMembership EINVAL'
|
||||
});
|
||||
socket.close();
|
||||
}
|
||||
Reference in new issue
Block a user