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

* Make common.skip() exit. Also add common.printSkipMessage() for partial skips. * Don't make needless things before skip PR-URL: https://github.com/nodejs/node/pull/14021 Fixes: https://github.com/nodejs/node/issues/14016 Reviewed-By: Refael Ackermann <refack@gmail.com>
42 lines
987 B
JavaScript
42 lines
987 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
// skip test in FreeBSD jails
|
|
if (common.inFreeBSDJail)
|
|
common.skip('In a FreeBSD jail');
|
|
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
|
|
let conns = 0;
|
|
const clientLocalPorts = [];
|
|
const serverRemotePorts = [];
|
|
const client = new net.Socket();
|
|
const server = net.createServer((socket) => {
|
|
serverRemotePorts.push(socket.remotePort);
|
|
socket.end();
|
|
});
|
|
|
|
server.on('close', common.mustCall(() => {
|
|
assert.deepStrictEqual(clientLocalPorts, serverRemotePorts,
|
|
'client and server should agree on the ports used');
|
|
assert.strictEqual(2, conns);
|
|
}));
|
|
|
|
server.listen(0, common.localhostIPv4, connect);
|
|
|
|
function connect() {
|
|
if (conns === 2) {
|
|
server.close();
|
|
return;
|
|
}
|
|
|
|
conns++;
|
|
client.once('close', connect);
|
|
assert.strictEqual(
|
|
client,
|
|
client.connect(server.address().port, common.localhostIPv4, () => {
|
|
clientLocalPorts.push(client.localPort);
|
|
})
|
|
);
|
|
}
|