mirror of
https://github.com/nodejs/node.git
synced 2025-05-20 23:55:47 +00:00

The call to assert.deepStrictEqual() has a string literal for its third argument. Unfortunately, a side effect of that is that the values of the first two arguments are not displayed if there is an AssertionError. That information is useful for debugging. PR-URL: https://github.com/nodejs/node/pull/20702 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
42 lines
964 B
JavaScript
42 lines
964 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(() => {
|
|
// client and server should agree on the ports used
|
|
assert.deepStrictEqual(clientLocalPorts, serverRemotePorts);
|
|
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);
|
|
})
|
|
);
|
|
}
|