node/test/sequential/test-net-localport.js
Antoine du Hamel 646e19e2b4
test: ensure assertions are reachable in test/sequential
PR-URL: https://github.com/nodejs/node/pull/60412
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
2025-10-29 16:29:39 +01:00

21 lines
588 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const net = require('net');
const server = net.createServer(common.mustCall((socket) => {
assert.strictEqual(socket.remotePort, common.PORT);
socket.end();
socket.on('close', function() {
server.close();
});
})).listen(0).on('listening', common.mustCall(function() {
const client = net.connect({
host: '127.0.0.1',
port: this.address().port,
localPort: common.PORT,
}).on('connect', common.mustCall(() => {
assert.strictEqual(client.localPort, common.PORT);
}));
}));