0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-25 08:19:38 +01:00
nodejs/test/internet/test-dgram-membership.js
Antoine du Hamel f57e9c36ab
test: add trailing commas in test/internet
PR-URL: https://github.com/nodejs/node/pull/46407
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
2023-02-01 10:46:06 +01:00

34 lines
821 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();
}