0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 23:43:09 +01:00
nodejs/test/parallel/test-net-connect-options-ipv6.js
Sakthipriyan Vairamani 69298d36cf test: formatting skip messages for TAP parsing
This patch makes the skip messages consistent so that the TAP plugin
in CI can parse the messages properly. The format will be

    1..0 # Skipped: [Actual reason why the test is skipped]

PR-URL: https://github.com/nodejs/io.js/pull/2109
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
2015-07-20 15:46:30 +05:30

58 lines
1.3 KiB
JavaScript

'use strict';
var common = require('../common');
var assert = require('assert');
var net = require('net');
var dns = require('dns');
if (!common.hasIPv6) {
console.log('1..0 # Skipped: no IPv6 support');
return;
}
var serverGotEnd = false;
var clientGotEnd = false;
dns.lookup('localhost', 6, function(err) {
if (err) {
console.error('Looks like IPv6 is not really supported');
console.error(err);
return;
}
var server = net.createServer({allowHalfOpen: true}, function(socket) {
socket.resume();
socket.on('end', function() {
serverGotEnd = true;
});
socket.end();
});
server.listen(common.PORT, '::1', function() {
var client = net.connect({
host: 'localhost',
port: common.PORT,
family: 6,
allowHalfOpen: true
}, function() {
console.error('client connect cb');
client.resume();
client.on('end', function() {
clientGotEnd = true;
setTimeout(function() {
assert(client.writable);
client.end();
}, 10);
});
client.on('close', function() {
server.close();
});
});
});
process.on('exit', function() {
console.error('exit', serverGotEnd, clientGotEnd);
assert(serverGotEnd);
assert(clientGotEnd);
});
});