mirror of
https://github.com/nodejs/node.git
synced 2025-05-01 17:03:34 +00:00

dgram sockets have a fair number of exposed private properties. This commit hides them all behind a single symbol property. PR-URL: https://github.com/nodejs/node/pull/21923 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Wyatt Preul <wpreul@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
20 lines
634 B
JavaScript
20 lines
634 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
const common = require('../common');
|
|
const dgram = require('dgram');
|
|
const { kStateSymbol } = require('internal/dgram');
|
|
const socket = dgram.createSocket('udp4');
|
|
const { handle } = socket[kStateSymbol];
|
|
const lookup = handle.lookup;
|
|
|
|
// Test the scenario where the socket is closed during a bind operation.
|
|
handle.bind = common.mustNotCall('bind() should not be called.');
|
|
|
|
handle.lookup = common.mustCall(function(address, callback) {
|
|
socket.close(common.mustCall(() => {
|
|
lookup.call(this, address, callback);
|
|
}));
|
|
});
|
|
|
|
socket.bind(common.mustNotCall('Socket should not bind.'));
|