Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: refactor test-net-connect-options-ipv6 #4395

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
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
21 changes: 3 additions & 18 deletions test/parallel/test-net-connect-options-ipv6.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,20 @@
const common = require('../common');
const assert = require('assert');
const net = require('net');
const dns = require('dns');

if (!common.hasIPv6) {
console.log('1..0 # Skipped: no IPv6 support');
return;
}

var serverGotEnd = false;
var clientGotEnd = false;

const hosts = common.localIPv6Hosts;
var hostIdx = 0;
var host = hosts[hostIdx];
var localhostTries = 10;

const server = net.createServer({allowHalfOpen: true}, function(socket) {
socket.resume();
socket.on('end', function() {
serverGotEnd = true;
});
socket.on('end', common.mustCall(function() {}));
socket.end();
});

Expand All @@ -36,13 +30,12 @@ function tryConnect() {
}, function() {
console.error('client connect cb');
client.resume();
client.on('end', function() {
clientGotEnd = true;
client.on('end', common.mustCall(function() {
setTimeout(function() {
assert(client.writable);
client.end();
}, 10);
});
}));
client.on('close', function() {
server.close();
});
Expand All @@ -54,18 +47,10 @@ function tryConnect() {
tryConnect();
else {
console.log('1..0 # Skipped: no IPv6 localhost support');
process.removeListener('exit', onExit);
server.close();
}
return;
}
throw err;
});
}

process.on('exit', onExit);
function onExit() {
console.error('exit', serverGotEnd, clientGotEnd);
assert(serverGotEnd);
assert(clientGotEnd);
}