Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "SmartOS fixes for the test suite"
This reverts commit a45f066.
  • Loading branch information
treysis committed Mar 28, 2021
commit ea90294c40332e2c2b261474c91deecc5fbcadab
36 changes: 12 additions & 24 deletions test/parallel/test-net-connect-options-port.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const net = require('net');
}
}, expectedConnections));

server.listen(0, common.localhostIPv4, common.mustCall(() => {
server.listen(0, 'localhost', common.mustCall(() => {
const port = server.address().port;

// Total connections = 3 * 4(canConnect) * 6(doConnect) = 72
Expand Down Expand Up @@ -133,35 +133,28 @@ function doConnect(args, getCb) {
}

function syncFailToConnect(port, assertErr, optOnly) {
const family = 4;
if (!optOnly) {
// connect(port, cb) and connect(port)
const portArgFunctions = doConnect([{ port, family }],
() => common.mustNotCall());
const portArgFunctions = doConnect([port], () => common.mustNotCall());
for (const fn of portArgFunctions) {
assert.throws(fn, assertErr, `${fn.name}(${port})`);
}

// connect(port, host, cb) and connect(port, host)
const portHostArgFunctions = doConnect([{ port,
host: 'localhost',
family }],
const portHostArgFunctions = doConnect([port, 'localhost'],
() => common.mustNotCall());
for (const fn of portHostArgFunctions) {
assert.throws(fn, assertErr, `${fn.name}(${port}, 'localhost')`);
}
}
// connect({port}, cb) and connect({port})
const portOptFunctions = doConnect([{ port, family }],
() => common.mustNotCall());
const portOptFunctions = doConnect([{ port }], () => common.mustNotCall());
for (const fn of portOptFunctions) {
assert.throws(fn, assertErr, `${fn.name}({port: ${port}})`);
}

// connect({port, host}, cb) and connect({port, host})
const portHostOptFunctions = doConnect([{ port: port,
host: 'localhost',
family }],
const portHostOptFunctions = doConnect([{ port: port, host: 'localhost' }],
() => common.mustNotCall());
for (const fn of portHostOptFunctions) {
assert.throws(fn,
Expand All @@ -172,30 +165,27 @@ function syncFailToConnect(port, assertErr, optOnly) {

function canConnect(port) {
const noop = () => common.mustCall();
const family = 4;

// connect(port, cb) and connect(port)
const portArgFunctions = doConnect([{ port, family }], noop);
const portArgFunctions = doConnect([port], noop);
for (const fn of portArgFunctions) {
fn();
}

// connect(port, host, cb) and connect(port, host)
const portHostArgFunctions = doConnect([{ port, host: 'localhost', family }],
noop);
const portHostArgFunctions = doConnect([port, 'localhost'], noop);
for (const fn of portHostArgFunctions) {
fn();
}

// connect({port}, cb) and connect({port})
const portOptFunctions = doConnect([{ port, family }], noop);
const portOptFunctions = doConnect([{ port }], noop);
for (const fn of portOptFunctions) {
fn();
}

// connect({port, host}, cb) and connect({port, host})
const portHostOptFns = doConnect([{ port, host: 'localhost', family }],
noop);
const portHostOptFns = doConnect([{ port, host: 'localhost' }], noop);
for (const fn of portHostOptFns) {
fn();
}
Expand All @@ -208,22 +198,20 @@ function asyncFailToConnect(port) {
});

const dont = () => common.mustNotCall();
const family = 4;
// connect(port, cb) and connect(port)
const portArgFunctions = doConnect([{ port, family }], dont);
const portArgFunctions = doConnect([port], dont);
for (const fn of portArgFunctions) {
fn().on('error', onError());
}

// connect({port}, cb) and connect({port})
const portOptFunctions = doConnect([{ port, family }], dont);
const portOptFunctions = doConnect([{ port }], dont);
for (const fn of portOptFunctions) {
fn().on('error', onError());
}

// connect({port, host}, cb) and connect({port, host})
const portHostOptFns = doConnect([{ port, host: 'localhost', family }],
dont);
const portHostOptFns = doConnect([{ port, host: 'localhost' }], dont);
for (const fn of portHostOptFns) {
fn().on('error', onError());
}
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-net-pingpong.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
pingPongTest(common.PIPE);
pingPongTest(0);
pingPongTest(0, '127.0.0.1');
pingPongTest(0, 'localhost');
if (common.hasIPv6)
pingPongTest(0, '::1');
9 changes: 3 additions & 6 deletions test/parallel/test-net-remote-address-port.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,9 @@ const server = net.createServer(common.mustCall(function(socket) {
socket.resume();
}, 2));

server.listen(0, '127.0.0.1', function() {
const client = net.createConnection({ port: this.address().port,
host: 'localhost',
family: 4 });
const client2 = net.createConnection({ port: this.address().port,
family: 4 });
server.listen(0, 'localhost', function() {
const client = net.createConnection(this.address().port, 'localhost');
const client2 = net.createConnection(this.address().port);
client.on('connect', function() {
assert.ok(remoteAddrCandidates.includes(client.remoteAddress));
assert.ok(remoteFamilyCandidates.includes(client.remoteFamily));
Expand Down
6 changes: 2 additions & 4 deletions test/parallel/test-net-writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ const net = require('net');
const server = net.createServer(common.mustCall(function(s) {
server.close();
s.end();
})).listen(0, common.localhostIPv4, common.mustCall(function() {
const socket = net.connect({ port: this.address().port,
host: 'localhost',
family: 4 });
})).listen(0, 'localhost', common.mustCall(function() {
const socket = net.connect(this.address().port, 'localhost');
socket.on('end', common.mustCall(() => {
assert.strictEqual(socket.writable, true);
socket.write('hello world');
Expand Down
4 changes: 2 additions & 2 deletions test/sequential/test-https-connect-localport.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ const assert = require('assert');
res.end();
}));

server.listen(0, common.localhostIPv4, common.mustCall(() => {
server.listen(0, 'localhost', common.mustCall(() => {
const port = server.address().port;
const req = https.get({
host: 'localhost',
pathname: '/',
port,
family: 4,
// family: 4,
Comment thread
treysis marked this conversation as resolved.
Outdated
localPort: common.PORT,
rejectUnauthorized: false,
}, common.mustCall(() => {
Expand Down