Renaming tcp tests to net tests
authorMicheil Smith <micheil@brandedcode.com>
Fri, 18 Jun 2010 17:34:56 +0000 (10:34 -0700)
committerRyan Dahl <ry@tinyclouds.org>
Fri, 18 Jun 2010 17:34:56 +0000 (10:34 -0700)
22 files changed:
test/pummel/test-net-many-clients.js [new file with mode: 0644]
test/pummel/test-net-pause.js [new file with mode: 0644]
test/pummel/test-net-pingpong-delay.js [new file with mode: 0644]
test/pummel/test-net-pingpong.js [new file with mode: 0644]
test/pummel/test-net-throttle.js [new file with mode: 0644]
test/pummel/test-net-timeout.js [new file with mode: 0644]
test/pummel/test-net-tls.js [new file with mode: 0644]
test/pummel/test-tcp-many-clients.js [deleted file]
test/pummel/test-tcp-pause.js [deleted file]
test/pummel/test-tcp-pingpong-delay.js [deleted file]
test/pummel/test-tcp-pingpong.js [deleted file]
test/pummel/test-tcp-throttle.js [deleted file]
test/pummel/test-tcp-timeout.js [deleted file]
test/pummel/test-tcp-tls.js [deleted file]
test/simple/test-net-binary.js [new file with mode: 0644]
test/simple/test-net-keepalive.js [new file with mode: 0644]
test/simple/test-net-reconnect.js [new file with mode: 0644]
test/simple/test-net-tls.js [new file with mode: 0644]
test/simple/test-tcp-binary.js [deleted file]
test/simple/test-tcp-keepalive.js [deleted file]
test/simple/test-tcp-reconnect.js [deleted file]
test/simple/test-tcp-tls.js [deleted file]

diff --git a/test/pummel/test-net-many-clients.js b/test/pummel/test-net-many-clients.js
new file mode 100644 (file)
index 0000000..9cff30b
--- /dev/null
@@ -0,0 +1,81 @@
+require("../common");
+net = require("net");
+// settings
+var bytes = 1024*40;
+var concurrency = 100;
+var connections_per_client = 5;
+
+// measured
+var total_connections = 0;
+
+var body = "";
+for (var i = 0; i < bytes; i++) {
+  body += "C";
+}
+
+var server = net.createServer(function (c) {
+  c.addListener("connect", function () {
+    total_connections++;
+    print("#");
+    c.write(body);
+    c.end();
+  });
+});
+
+function runClient (callback) {
+  var client = net.createConnection(PORT);
+
+  client.connections = 0;
+
+  client.setEncoding("utf8");
+
+  client.addListener("connect", function () {
+    print("c");
+    client.recved = "";
+    client.connections += 1;
+  });
+
+  client.addListener("data", function (chunk) {
+    this.recved += chunk;
+  });
+
+  client.addListener("end", function () {
+    client.end();
+  });
+
+  client.addListener("error", function (e) {
+    puts("\n\nERROOOOOr");
+    throw e;
+  });
+
+  client.addListener("close", function (had_error) {
+    print(".");
+    assert.equal(false, had_error);
+    assert.equal(bytes, client.recved.length);
+
+    if (client.fd) {
+      puts(client.fd);
+    }
+    assert.ok(!client.fd);
+
+    if (this.connections < connections_per_client) {
+      this.connect(PORT);
+    } else {
+      callback();
+    }
+  });
+}
+
+server.listen(PORT, function () {
+  var finished_clients = 0;
+  for (var i = 0; i < concurrency; i++) {
+    runClient(function () {
+      if (++finished_clients == concurrency) server.close();
+    });
+  }
+});
+
+process.addListener("exit", function () {
+  assert.equal(connections_per_client * concurrency, total_connections);
+  puts("\nokay!");
+});
diff --git a/test/pummel/test-net-pause.js b/test/pummel/test-net-pause.js
new file mode 100644 (file)
index 0000000..de84c0e
--- /dev/null
@@ -0,0 +1,67 @@
+require("../common");
+net = require("net");
+N = 200;
+
+server = net.createServer(function (connection) {
+  function write (j) {
+    if (j >= N) {
+      connection.end();
+      return;
+    }
+    setTimeout(function () {
+      connection.write("C");
+      write(j+1);
+    }, 10);
+  }
+  write(0);
+});
+server.listen(PORT);
+
+
+recv = "";
+chars_recved = 0;
+
+client = net.createConnection(PORT);
+client.setEncoding("ascii");
+client.addListener("data", function (d) {
+    print(d);
+    recv += d;
+});
+
+setTimeout(function () {
+  chars_recved = recv.length;
+  puts("pause at: " + chars_recved);
+  assert.equal(true, chars_recved > 1);
+  client.pause();
+  setTimeout(function () {
+    puts("resume at: " + chars_recved);
+    assert.equal(chars_recved, recv.length);
+    client.resume();
+
+    setTimeout(function () {
+      chars_recved = recv.length;
+      puts("pause at: " + chars_recved);
+      client.pause();
+
+      setTimeout(function () {
+        puts("resume at: " + chars_recved);
+        assert.equal(chars_recved, recv.length);
+        client.resume();
+
+      }, 500);
+
+    }, 500);
+
+  }, 500);
+
+}, 500);
+
+client.addListener("end", function () {
+  server.close();
+  client.end();
+});
+
+process.addListener("exit", function () {
+  assert.equal(N, recv.length);
+  debug("Exit");
+});
diff --git a/test/pummel/test-net-pingpong-delay.js b/test/pummel/test-net-pingpong-delay.js
new file mode 100644 (file)
index 0000000..5854674
--- /dev/null
@@ -0,0 +1,91 @@
+require("../common");
+net = require("net");
+
+
+var tests_run = 0;
+
+function pingPongTest (port, host, on_complete) {
+  var N = 100;
+  var DELAY = 1;
+  var count = 0;
+  var client_ended = false;
+
+  var server = net.createServer(function (socket) {
+    socket.setEncoding("utf8");
+
+    socket.addListener("data", function (data) {
+      puts(data);
+      assert.equal("PING", data);
+      assert.equal("open", socket.readyState);
+      assert.equal(true, count <= N);
+      setTimeout(function () {
+        assert.equal("open", socket.readyState);
+        socket.write("PONG");
+      }, DELAY);
+    });
+
+    socket.addListener("timeout", function () {
+      debug("server-side timeout!!");
+      assert.equal(false, true);
+    });
+
+    socket.addListener("end", function () {
+      puts("server-side socket EOF");
+      assert.equal("writeOnly", socket.readyState);
+      socket.end();
+    });
+
+    socket.addListener("close", function (had_error) {
+      puts("server-side socket.end");
+      assert.equal(false, had_error);
+      assert.equal("closed", socket.readyState);
+      socket.server.close();
+    });
+  });
+  server.listen(port, host);
+
+  var client = net.createConnection(port, host);
+
+  client.setEncoding("utf8");
+
+  client.addListener("connect", function () {
+    assert.equal("open", client.readyState);
+    client.write("PING");
+  });
+
+  client.addListener("data", function (data) {
+    puts(data);
+    assert.equal("PONG", data);
+    assert.equal("open", client.readyState);
+
+    setTimeout(function () {
+      assert.equal("open", client.readyState);
+      if (count++ < N) {
+        client.write("PING");
+      } else {
+        puts("closing client");
+        client.end();
+        client_ended = true;
+      }
+    }, DELAY);
+  });
+
+  client.addListener("timeout", function () {
+    debug("client-side timeout!!");
+    assert.equal(false, true);
+  });
+
+  client.addListener("close", function () {
+    puts("client.end");
+    assert.equal(N+1, count);
+    assert.ok(client_ended);
+    if (on_complete) on_complete();
+    tests_run += 1;
+  });
+}
+
+pingPongTest(PORT);
+
+process.addListener("exit", function () {
+  assert.equal(1, tests_run);
+});
diff --git a/test/pummel/test-net-pingpong.js b/test/pummel/test-net-pingpong.js
new file mode 100644 (file)
index 0000000..d96e398
--- /dev/null
@@ -0,0 +1,96 @@
+require("../common");
+net = require("net");
+
+var tests_run = 0;
+
+function pingPongTest (port, host, on_complete) {
+  var N = 1000;
+  var count = 0;
+  var sent_final_ping = false;
+
+  var server = net.createServer(function (socket) {
+    assert.equal(true, socket.remoteAddress !== null);
+    assert.equal(true, socket.remoteAddress !== undefined);
+    if (host === "127.0.0.1" || host === "localhost" || !host) {
+      assert.equal(socket.remoteAddress, "127.0.0.1");
+    } else {
+      puts('host = ' + host + ', remoteAddress = ' + socket.remoteAddress);
+      assert.equal(socket.remoteAddress, "::1");
+    }
+
+    socket.setEncoding("utf8");
+    socket.setNoDelay();
+    socket.timeout = 0;
+
+    socket.addListener("data", function (data) {
+      puts("server got: " + JSON.stringify(data));
+      assert.equal("open", socket.readyState);
+      assert.equal(true, count <= N);
+      if (/PING/.exec(data)) {
+        socket.write("PONG");
+      }
+    });
+
+    socket.addListener("end", function () {
+      assert.equal("writeOnly", socket.readyState);
+      socket.end();
+    });
+
+    socket.addListener("close", function (had_error) {
+      assert.equal(false, had_error);
+      assert.equal("closed", socket.readyState);
+      socket.server.close();
+    });
+  });
+  server.listen(port, host);
+
+  var client = net.createConnection(port, host);
+
+  client.setEncoding("utf8");
+
+  client.addListener("connect", function () {
+    assert.equal("open", client.readyState);
+    client.write("PING");
+  });
+
+  client.addListener("data", function (data) {
+    puts('client got: ' + data);
+
+    assert.equal("PONG", data);
+    count += 1;
+
+    if (sent_final_ping) {
+      assert.equal("readOnly", client.readyState);
+      return;
+    } else {
+      assert.equal("open", client.readyState);
+    }
+
+    if (count < N) {
+      client.write("PING");
+    } else {
+      sent_final_ping = true;
+      client.write("PING");
+      client.end();
+    }
+  });
+
+  client.addListener("close", function () {
+    assert.equal(N+1, count);
+    assert.equal(true, sent_final_ping);
+    if (on_complete) on_complete();
+    tests_run += 1;
+  });
+}
+
+/* All are run at once, so run on different ports */
+pingPongTest(PORT, "localhost");
+pingPongTest(PORT+1, null);
+
+// This IPv6 isn't working on Solaris
+var solaris = /sunos/i.test(process.platform);
+if (!solaris) pingPongTest(PORT+2, "::1");
+
+process.addListener("exit", function () {
+  assert.equal(solaris ? 2 : 3, tests_run);
+});
diff --git a/test/pummel/test-net-throttle.js b/test/pummel/test-net-throttle.js
new file mode 100644 (file)
index 0000000..8da7239
--- /dev/null
@@ -0,0 +1,55 @@
+require("../common");
+net = require("net");
+N = 160*1024; // 30kb
+
+puts("build big string");
+var body = "";
+for (var i = 0; i < N; i++) {
+  body += "C";
+}
+
+puts("start server on port " + PORT);
+
+server = net.createServer(function (connection) {
+  connection.addListener("connect", function () {
+    assert.equal(false, connection.write(body));
+    connection.end();
+  });
+});
+server.listen(PORT);
+
+
+chars_recved = 0;
+npauses = 0;
+
+
+var paused = false;
+client = net.createConnection(PORT);
+client.setEncoding("ascii");
+client.addListener("data", function (d) {
+  chars_recved += d.length;
+  puts("got " + chars_recved);
+  if (!paused) {
+    client.pause();
+    npauses += 1;
+    paused = true;
+    puts("pause");
+    x = chars_recved;
+    setTimeout(function () {
+      assert.equal(chars_recved, x);
+      client.resume();
+      puts("resume");
+      paused = false;
+    }, 100);
+  }
+});
+
+client.addListener("end", function () {
+  server.close();
+  client.end();
+});
+
+process.addListener("exit", function () {
+  assert.equal(N, chars_recved);
+  assert.equal(true, npauses > 2);
+});
diff --git a/test/pummel/test-net-timeout.js b/test/pummel/test-net-timeout.js
new file mode 100644 (file)
index 0000000..6e4600d
--- /dev/null
@@ -0,0 +1,85 @@
+require("../common");
+net = require("net");
+exchanges = 0;
+starttime = null;
+timeouttime = null;
+timeout = 1000;
+
+var echo_server = net.createServer(function (socket) {
+  socket.setTimeout(timeout);
+
+  socket.addListener("timeout", function () {
+    puts("server timeout");
+    timeouttime = new Date;
+    p(timeouttime);
+    socket.destroy();
+  });
+
+  socket.addListener("error", function (e) {
+    throw new Error("Server side socket should not get error. We disconnect willingly.");
+  })
+
+  socket.addListener("data", function (d) {
+    puts(d);
+    socket.write(d);
+  });
+
+  socket.addListener("end", function () {
+    socket.end();
+  });
+});
+
+echo_server.listen(PORT, function () {
+  puts("server listening at " + PORT);
+});
+
+var client = net.createConnection(PORT);
+client.setEncoding("UTF8");
+client.setTimeout(0); // disable the timeout for client
+client.addListener("connect", function () {
+  puts("client connected.");
+  client.write("hello\r\n");
+});
+
+client.addListener("data", function (chunk) {
+  assert.equal("hello\r\n", chunk);
+  if (exchanges++ < 5) {
+    setTimeout(function () {
+      puts("client write 'hello'");
+      client.write("hello\r\n");
+    }, 500);
+
+    if (exchanges == 5) {
+      puts("wait for timeout - should come in " + timeout + " ms");
+      starttime = new Date;
+      p(starttime);
+    }
+  }
+});
+
+client.addListener("timeout", function () {
+  throw new Error("client timeout - this shouldn't happen");
+});
+
+client.addListener("end", function () {
+  puts("client end");
+  client.end();
+});
+
+client.addListener("close", function () {
+  puts("client disconnect");
+  echo_server.close();
+});
+
+process.addListener("exit", function () {
+  assert.ok(starttime != null);
+  assert.ok(timeouttime != null);
+
+  diff = timeouttime - starttime;
+  puts("diff = " + diff);
+
+  assert.ok(timeout < diff);
+
+  // Allow for 800 milliseconds more
+  assert.ok(diff < timeout + 800);
+});
diff --git a/test/pummel/test-net-tls.js b/test/pummel/test-net-tls.js
new file mode 100644 (file)
index 0000000..d156b93
--- /dev/null
@@ -0,0 +1,122 @@
+require("../common");
+tcp = require("tcp");
+fs=require("fs");
+
+var tests_run = 0;
+
+function tlsTest (port, host, caPem, keyPem, certPem) {
+  var N = 50;
+  var count = 0;
+  var sent_final_ping = false;
+
+  var server = tcp.createServer(function (socket) {
+    assert.equal(true, socket.remoteAddress !== null);
+    assert.equal(true, socket.remoteAddress !== undefined);
+    if (host === "127.0.0.1")
+      assert.equal(socket.remoteAddress, "127.0.0.1");
+    else if (host == null)
+      assert.equal(socket.remoteAddress, "127.0.0.1");
+
+    socket.setEncoding("utf8");
+    socket.setNoDelay();
+    socket.timeout = 0;
+
+    socket.addListener("data", function (data) {
+      var verified = socket.verifyPeer();
+      var peerDN = socket.getPeerCertificate("DNstring");
+      assert.equal(verified, 1);
+      assert.equal(peerDN, "C=UK,ST=Acknack Ltd,L=Rhys Jones,O=node.js,"
+                           + "OU=Test TLS Certificate,CN=localhost");
+      puts("server got: " + JSON.stringify(data));
+      assert.equal("open", socket.readyState);
+      assert.equal(true, count <= N);
+      if (/PING/.exec(data)) {
+        socket.write("PONG");
+      }
+    });
+
+    socket.addListener("end", function () {
+      assert.equal("writeOnly", socket.readyState);
+      socket.end();
+    });
+
+    socket.addListener("close", function (had_error) {
+      assert.equal(false, had_error);
+      assert.equal("closed", socket.readyState);
+      socket.server.close();
+    });
+  });
+
+  server.setSecure('X509_PEM', caPem, 0, keyPem, certPem);
+  server.listen(port, host);
+
+  var client = tcp.createConnection(port, host);
+
+  client.setEncoding("utf8");
+  client.setSecure('X509_PEM', caPem, 0, keyPem, caPem);
+
+  client.addListener("connect", function () {
+    assert.equal("open", client.readyState);
+    var verified = client.verifyPeer();
+    var peerDN = client.getPeerCertificate("DNstring");
+    assert.equal(verified, 1);
+    assert.equal(peerDN, "C=UK,ST=Acknack Ltd,L=Rhys Jones,O=node.js,"
+                        + "OU=Test TLS Certificate,CN=localhost");
+    client.write("PING");
+  });
+
+  client.addListener("data", function (data) {
+    assert.equal("PONG", data);
+    count += 1;
+
+    puts("client got PONG");
+
+    if (sent_final_ping) {
+      assert.equal("readOnly", client.readyState);
+      return;
+    } else {
+      assert.equal("open", client.readyState);
+    }
+
+    if (count < N) {
+      client.write("PING");
+    } else {
+      sent_final_ping = true;
+      client.write("PING");
+      client.end();
+    }
+  });
+
+  client.addListener("close", function () {
+    assert.equal(N+1, count);
+    assert.equal(true, sent_final_ping);
+    tests_run += 1;
+  });
+}
+
+
+var have_tls;
+try {
+  var dummy_server = tcp.createServer();
+  dummy_server.setSecure();
+  have_tls=true;
+} catch (e) {
+  have_tls=false;
+} 
+
+if (have_tls) {
+  var caPem = fs.readFileSync(fixturesDir+"/test_ca.pem");
+  var certPem = fs.readFileSync(fixturesDir+"/test_cert.pem");
+  var keyPem = fs.readFileSync(fixturesDir+"/test_key.pem");
+
+  /* All are run at once, so run on different ports */
+  tlsTest(PORT, "localhost", caPem, keyPem, certPem);
+  tlsTest(PORT+1, null, caPem, keyPem, certPem);
+
+  process.addListener("exit", function () {
+    assert.equal(2, tests_run);
+  });
+} else {
+  puts("Not compiled with TLS support -- skipping test");
+  process.exit(0);
+}
diff --git a/test/pummel/test-tcp-many-clients.js b/test/pummel/test-tcp-many-clients.js
deleted file mode 100644 (file)
index 9cff30b..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-require("../common");
-net = require("net");
-// settings
-var bytes = 1024*40;
-var concurrency = 100;
-var connections_per_client = 5;
-
-// measured
-var total_connections = 0;
-
-var body = "";
-for (var i = 0; i < bytes; i++) {
-  body += "C";
-}
-
-var server = net.createServer(function (c) {
-  c.addListener("connect", function () {
-    total_connections++;
-    print("#");
-    c.write(body);
-    c.end();
-  });
-});
-
-function runClient (callback) {
-  var client = net.createConnection(PORT);
-
-  client.connections = 0;
-
-  client.setEncoding("utf8");
-
-  client.addListener("connect", function () {
-    print("c");
-    client.recved = "";
-    client.connections += 1;
-  });
-
-  client.addListener("data", function (chunk) {
-    this.recved += chunk;
-  });
-
-  client.addListener("end", function () {
-    client.end();
-  });
-
-  client.addListener("error", function (e) {
-    puts("\n\nERROOOOOr");
-    throw e;
-  });
-
-  client.addListener("close", function (had_error) {
-    print(".");
-    assert.equal(false, had_error);
-    assert.equal(bytes, client.recved.length);
-
-    if (client.fd) {
-      puts(client.fd);
-    }
-    assert.ok(!client.fd);
-
-    if (this.connections < connections_per_client) {
-      this.connect(PORT);
-    } else {
-      callback();
-    }
-  });
-}
-
-server.listen(PORT, function () {
-  var finished_clients = 0;
-  for (var i = 0; i < concurrency; i++) {
-    runClient(function () {
-      if (++finished_clients == concurrency) server.close();
-    });
-  }
-});
-
-process.addListener("exit", function () {
-  assert.equal(connections_per_client * concurrency, total_connections);
-  puts("\nokay!");
-});
diff --git a/test/pummel/test-tcp-pause.js b/test/pummel/test-tcp-pause.js
deleted file mode 100644 (file)
index de84c0e..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-require("../common");
-net = require("net");
-N = 200;
-
-server = net.createServer(function (connection) {
-  function write (j) {
-    if (j >= N) {
-      connection.end();
-      return;
-    }
-    setTimeout(function () {
-      connection.write("C");
-      write(j+1);
-    }, 10);
-  }
-  write(0);
-});
-server.listen(PORT);
-
-
-recv = "";
-chars_recved = 0;
-
-client = net.createConnection(PORT);
-client.setEncoding("ascii");
-client.addListener("data", function (d) {
-    print(d);
-    recv += d;
-});
-
-setTimeout(function () {
-  chars_recved = recv.length;
-  puts("pause at: " + chars_recved);
-  assert.equal(true, chars_recved > 1);
-  client.pause();
-  setTimeout(function () {
-    puts("resume at: " + chars_recved);
-    assert.equal(chars_recved, recv.length);
-    client.resume();
-
-    setTimeout(function () {
-      chars_recved = recv.length;
-      puts("pause at: " + chars_recved);
-      client.pause();
-
-      setTimeout(function () {
-        puts("resume at: " + chars_recved);
-        assert.equal(chars_recved, recv.length);
-        client.resume();
-
-      }, 500);
-
-    }, 500);
-
-  }, 500);
-
-}, 500);
-
-client.addListener("end", function () {
-  server.close();
-  client.end();
-});
-
-process.addListener("exit", function () {
-  assert.equal(N, recv.length);
-  debug("Exit");
-});
diff --git a/test/pummel/test-tcp-pingpong-delay.js b/test/pummel/test-tcp-pingpong-delay.js
deleted file mode 100644 (file)
index 5854674..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-require("../common");
-net = require("net");
-
-
-var tests_run = 0;
-
-function pingPongTest (port, host, on_complete) {
-  var N = 100;
-  var DELAY = 1;
-  var count = 0;
-  var client_ended = false;
-
-  var server = net.createServer(function (socket) {
-    socket.setEncoding("utf8");
-
-    socket.addListener("data", function (data) {
-      puts(data);
-      assert.equal("PING", data);
-      assert.equal("open", socket.readyState);
-      assert.equal(true, count <= N);
-      setTimeout(function () {
-        assert.equal("open", socket.readyState);
-        socket.write("PONG");
-      }, DELAY);
-    });
-
-    socket.addListener("timeout", function () {
-      debug("server-side timeout!!");
-      assert.equal(false, true);
-    });
-
-    socket.addListener("end", function () {
-      puts("server-side socket EOF");
-      assert.equal("writeOnly", socket.readyState);
-      socket.end();
-    });
-
-    socket.addListener("close", function (had_error) {
-      puts("server-side socket.end");
-      assert.equal(false, had_error);
-      assert.equal("closed", socket.readyState);
-      socket.server.close();
-    });
-  });
-  server.listen(port, host);
-
-  var client = net.createConnection(port, host);
-
-  client.setEncoding("utf8");
-
-  client.addListener("connect", function () {
-    assert.equal("open", client.readyState);
-    client.write("PING");
-  });
-
-  client.addListener("data", function (data) {
-    puts(data);
-    assert.equal("PONG", data);
-    assert.equal("open", client.readyState);
-
-    setTimeout(function () {
-      assert.equal("open", client.readyState);
-      if (count++ < N) {
-        client.write("PING");
-      } else {
-        puts("closing client");
-        client.end();
-        client_ended = true;
-      }
-    }, DELAY);
-  });
-
-  client.addListener("timeout", function () {
-    debug("client-side timeout!!");
-    assert.equal(false, true);
-  });
-
-  client.addListener("close", function () {
-    puts("client.end");
-    assert.equal(N+1, count);
-    assert.ok(client_ended);
-    if (on_complete) on_complete();
-    tests_run += 1;
-  });
-}
-
-pingPongTest(PORT);
-
-process.addListener("exit", function () {
-  assert.equal(1, tests_run);
-});
diff --git a/test/pummel/test-tcp-pingpong.js b/test/pummel/test-tcp-pingpong.js
deleted file mode 100644 (file)
index d96e398..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-require("../common");
-net = require("net");
-
-var tests_run = 0;
-
-function pingPongTest (port, host, on_complete) {
-  var N = 1000;
-  var count = 0;
-  var sent_final_ping = false;
-
-  var server = net.createServer(function (socket) {
-    assert.equal(true, socket.remoteAddress !== null);
-    assert.equal(true, socket.remoteAddress !== undefined);
-    if (host === "127.0.0.1" || host === "localhost" || !host) {
-      assert.equal(socket.remoteAddress, "127.0.0.1");
-    } else {
-      puts('host = ' + host + ', remoteAddress = ' + socket.remoteAddress);
-      assert.equal(socket.remoteAddress, "::1");
-    }
-
-    socket.setEncoding("utf8");
-    socket.setNoDelay();
-    socket.timeout = 0;
-
-    socket.addListener("data", function (data) {
-      puts("server got: " + JSON.stringify(data));
-      assert.equal("open", socket.readyState);
-      assert.equal(true, count <= N);
-      if (/PING/.exec(data)) {
-        socket.write("PONG");
-      }
-    });
-
-    socket.addListener("end", function () {
-      assert.equal("writeOnly", socket.readyState);
-      socket.end();
-    });
-
-    socket.addListener("close", function (had_error) {
-      assert.equal(false, had_error);
-      assert.equal("closed", socket.readyState);
-      socket.server.close();
-    });
-  });
-  server.listen(port, host);
-
-  var client = net.createConnection(port, host);
-
-  client.setEncoding("utf8");
-
-  client.addListener("connect", function () {
-    assert.equal("open", client.readyState);
-    client.write("PING");
-  });
-
-  client.addListener("data", function (data) {
-    puts('client got: ' + data);
-
-    assert.equal("PONG", data);
-    count += 1;
-
-    if (sent_final_ping) {
-      assert.equal("readOnly", client.readyState);
-      return;
-    } else {
-      assert.equal("open", client.readyState);
-    }
-
-    if (count < N) {
-      client.write("PING");
-    } else {
-      sent_final_ping = true;
-      client.write("PING");
-      client.end();
-    }
-  });
-
-  client.addListener("close", function () {
-    assert.equal(N+1, count);
-    assert.equal(true, sent_final_ping);
-    if (on_complete) on_complete();
-    tests_run += 1;
-  });
-}
-
-/* All are run at once, so run on different ports */
-pingPongTest(PORT, "localhost");
-pingPongTest(PORT+1, null);
-
-// This IPv6 isn't working on Solaris
-var solaris = /sunos/i.test(process.platform);
-if (!solaris) pingPongTest(PORT+2, "::1");
-
-process.addListener("exit", function () {
-  assert.equal(solaris ? 2 : 3, tests_run);
-});
diff --git a/test/pummel/test-tcp-throttle.js b/test/pummel/test-tcp-throttle.js
deleted file mode 100644 (file)
index 8da7239..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-require("../common");
-net = require("net");
-N = 160*1024; // 30kb
-
-puts("build big string");
-var body = "";
-for (var i = 0; i < N; i++) {
-  body += "C";
-}
-
-puts("start server on port " + PORT);
-
-server = net.createServer(function (connection) {
-  connection.addListener("connect", function () {
-    assert.equal(false, connection.write(body));
-    connection.end();
-  });
-});
-server.listen(PORT);
-
-
-chars_recved = 0;
-npauses = 0;
-
-
-var paused = false;
-client = net.createConnection(PORT);
-client.setEncoding("ascii");
-client.addListener("data", function (d) {
-  chars_recved += d.length;
-  puts("got " + chars_recved);
-  if (!paused) {
-    client.pause();
-    npauses += 1;
-    paused = true;
-    puts("pause");
-    x = chars_recved;
-    setTimeout(function () {
-      assert.equal(chars_recved, x);
-      client.resume();
-      puts("resume");
-      paused = false;
-    }, 100);
-  }
-});
-
-client.addListener("end", function () {
-  server.close();
-  client.end();
-});
-
-process.addListener("exit", function () {
-  assert.equal(N, chars_recved);
-  assert.equal(true, npauses > 2);
-});
diff --git a/test/pummel/test-tcp-timeout.js b/test/pummel/test-tcp-timeout.js
deleted file mode 100644 (file)
index 6e4600d..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-require("../common");
-net = require("net");
-exchanges = 0;
-starttime = null;
-timeouttime = null;
-timeout = 1000;
-
-var echo_server = net.createServer(function (socket) {
-  socket.setTimeout(timeout);
-
-  socket.addListener("timeout", function () {
-    puts("server timeout");
-    timeouttime = new Date;
-    p(timeouttime);
-    socket.destroy();
-  });
-
-  socket.addListener("error", function (e) {
-    throw new Error("Server side socket should not get error. We disconnect willingly.");
-  })
-
-  socket.addListener("data", function (d) {
-    puts(d);
-    socket.write(d);
-  });
-
-  socket.addListener("end", function () {
-    socket.end();
-  });
-});
-
-echo_server.listen(PORT, function () {
-  puts("server listening at " + PORT);
-});
-
-var client = net.createConnection(PORT);
-client.setEncoding("UTF8");
-client.setTimeout(0); // disable the timeout for client
-client.addListener("connect", function () {
-  puts("client connected.");
-  client.write("hello\r\n");
-});
-
-client.addListener("data", function (chunk) {
-  assert.equal("hello\r\n", chunk);
-  if (exchanges++ < 5) {
-    setTimeout(function () {
-      puts("client write 'hello'");
-      client.write("hello\r\n");
-    }, 500);
-
-    if (exchanges == 5) {
-      puts("wait for timeout - should come in " + timeout + " ms");
-      starttime = new Date;
-      p(starttime);
-    }
-  }
-});
-
-client.addListener("timeout", function () {
-  throw new Error("client timeout - this shouldn't happen");
-});
-
-client.addListener("end", function () {
-  puts("client end");
-  client.end();
-});
-
-client.addListener("close", function () {
-  puts("client disconnect");
-  echo_server.close();
-});
-
-process.addListener("exit", function () {
-  assert.ok(starttime != null);
-  assert.ok(timeouttime != null);
-
-  diff = timeouttime - starttime;
-  puts("diff = " + diff);
-
-  assert.ok(timeout < diff);
-
-  // Allow for 800 milliseconds more
-  assert.ok(diff < timeout + 800);
-});
diff --git a/test/pummel/test-tcp-tls.js b/test/pummel/test-tcp-tls.js
deleted file mode 100644 (file)
index d156b93..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-require("../common");
-tcp = require("tcp");
-fs=require("fs");
-
-var tests_run = 0;
-
-function tlsTest (port, host, caPem, keyPem, certPem) {
-  var N = 50;
-  var count = 0;
-  var sent_final_ping = false;
-
-  var server = tcp.createServer(function (socket) {
-    assert.equal(true, socket.remoteAddress !== null);
-    assert.equal(true, socket.remoteAddress !== undefined);
-    if (host === "127.0.0.1")
-      assert.equal(socket.remoteAddress, "127.0.0.1");
-    else if (host == null)
-      assert.equal(socket.remoteAddress, "127.0.0.1");
-
-    socket.setEncoding("utf8");
-    socket.setNoDelay();
-    socket.timeout = 0;
-
-    socket.addListener("data", function (data) {
-      var verified = socket.verifyPeer();
-      var peerDN = socket.getPeerCertificate("DNstring");
-      assert.equal(verified, 1);
-      assert.equal(peerDN, "C=UK,ST=Acknack Ltd,L=Rhys Jones,O=node.js,"
-                           + "OU=Test TLS Certificate,CN=localhost");
-      puts("server got: " + JSON.stringify(data));
-      assert.equal("open", socket.readyState);
-      assert.equal(true, count <= N);
-      if (/PING/.exec(data)) {
-        socket.write("PONG");
-      }
-    });
-
-    socket.addListener("end", function () {
-      assert.equal("writeOnly", socket.readyState);
-      socket.end();
-    });
-
-    socket.addListener("close", function (had_error) {
-      assert.equal(false, had_error);
-      assert.equal("closed", socket.readyState);
-      socket.server.close();
-    });
-  });
-
-  server.setSecure('X509_PEM', caPem, 0, keyPem, certPem);
-  server.listen(port, host);
-
-  var client = tcp.createConnection(port, host);
-
-  client.setEncoding("utf8");
-  client.setSecure('X509_PEM', caPem, 0, keyPem, caPem);
-
-  client.addListener("connect", function () {
-    assert.equal("open", client.readyState);
-    var verified = client.verifyPeer();
-    var peerDN = client.getPeerCertificate("DNstring");
-    assert.equal(verified, 1);
-    assert.equal(peerDN, "C=UK,ST=Acknack Ltd,L=Rhys Jones,O=node.js,"
-                        + "OU=Test TLS Certificate,CN=localhost");
-    client.write("PING");
-  });
-
-  client.addListener("data", function (data) {
-    assert.equal("PONG", data);
-    count += 1;
-
-    puts("client got PONG");
-
-    if (sent_final_ping) {
-      assert.equal("readOnly", client.readyState);
-      return;
-    } else {
-      assert.equal("open", client.readyState);
-    }
-
-    if (count < N) {
-      client.write("PING");
-    } else {
-      sent_final_ping = true;
-      client.write("PING");
-      client.end();
-    }
-  });
-
-  client.addListener("close", function () {
-    assert.equal(N+1, count);
-    assert.equal(true, sent_final_ping);
-    tests_run += 1;
-  });
-}
-
-
-var have_tls;
-try {
-  var dummy_server = tcp.createServer();
-  dummy_server.setSecure();
-  have_tls=true;
-} catch (e) {
-  have_tls=false;
-} 
-
-if (have_tls) {
-  var caPem = fs.readFileSync(fixturesDir+"/test_ca.pem");
-  var certPem = fs.readFileSync(fixturesDir+"/test_cert.pem");
-  var keyPem = fs.readFileSync(fixturesDir+"/test_key.pem");
-
-  /* All are run at once, so run on different ports */
-  tlsTest(PORT, "localhost", caPem, keyPem, certPem);
-  tlsTest(PORT+1, null, caPem, keyPem, certPem);
-
-  process.addListener("exit", function () {
-    assert.equal(2, tests_run);
-  });
-} else {
-  puts("Not compiled with TLS support -- skipping test");
-  process.exit(0);
-}
diff --git a/test/simple/test-net-binary.js b/test/simple/test-net-binary.js
new file mode 100644 (file)
index 0000000..9dc347a
--- /dev/null
@@ -0,0 +1,73 @@
+require("../common");
+tcp = require("tcp");
+
+binaryString = "";
+for (var i = 255; i >= 0; i--) {
+  var s = "'\\" + i.toString(8) + "'";
+  S = eval(s);
+  error( s
+       + " "
+       + JSON.stringify(S)
+       + " "
+       + JSON.stringify(String.fromCharCode(i)) 
+       + " "
+       + S.charCodeAt(0)
+       );
+  process.assert(S.charCodeAt(0) == i);
+  process.assert(S == String.fromCharCode(i));
+  binaryString += S;
+}
+
+var echoServer = tcp.createServer(function (connection) {
+  connection.setEncoding("binary");
+  connection.addListener("data", function (chunk) {
+    error("recved: " + JSON.stringify(chunk));
+    connection.write(chunk, "binary");
+  });
+  connection.addListener("end", function () {
+    connection.end();
+  });
+});
+echoServer.listen(PORT);
+
+var recv = "";
+var j = 0;
+
+var c = tcp.createConnection(PORT);
+
+c.setEncoding("binary");
+c.addListener("data", function (chunk) {
+  if (j < 256) {
+    error("write " + j);
+    c.write(String.fromCharCode(j), "binary");
+    j++;
+  } else {
+    c.end();
+  }
+  recv += chunk;
+});
+
+c.addListener("connect", function () {
+  c.write(binaryString, "binary");
+});
+
+c.addListener("close", function () {
+  p(recv);
+  echoServer.close();
+});
+
+process.addListener("exit", function () {
+  puts("recv: " + JSON.stringify(recv));
+
+  assert.equal(2*256, recv.length);
+
+  var a = recv.split("");
+
+  var first = a.slice(0,256).reverse().join("");
+  puts("first: " + JSON.stringify(first));
+
+  var second = a.slice(256,2*256).join("");
+  puts("second: " + JSON.stringify(second));
+
+  assert.equal(first, second);
+});
diff --git a/test/simple/test-net-keepalive.js b/test/simple/test-net-keepalive.js
new file mode 100644 (file)
index 0000000..adf5326
--- /dev/null
@@ -0,0 +1,28 @@
+require("../common");
+net = require('net');
+
+var serverConnection;
+var echoServer = net.createServer(function (connection) {
+  serverConnection = connection;
+  connection.setTimeout(0);
+  assert.notEqual(connection.setKeepAlive,undefined);
+  // send a keepalive packet after 1000 ms
+  connection.setKeepAlive(true,1000);
+  connection.addListener("end", function () {
+    connection.end();
+  });
+});
+echoServer.listen(PORT);
+
+var clientConnection = net.createConnection(PORT);
+clientConnection.setTimeout(0);
+
+setTimeout( function() {
+  // make sure both connections are still open
+  assert.equal(serverConnection.readyState,"open");
+  assert.equal(clientConnection.readyState,"open");
+  serverConnection.end();
+  clientConnection.end();
+  echoServer.close();
+}, 1200);
+
diff --git a/test/simple/test-net-reconnect.js b/test/simple/test-net-reconnect.js
new file mode 100644 (file)
index 0000000..9b297a7
--- /dev/null
@@ -0,0 +1,55 @@
+require("../common");
+net = require('net');
+var N = 50;
+
+var c = 0;
+var client_recv_count = 0;
+var disconnect_count = 0;
+
+var server = net.createServer(function (socket) {
+  socket.addListener("connect", function () {
+    socket.write("hello\r\n");
+  });
+
+  socket.addListener("end", function () {
+    socket.end();
+  });
+
+  socket.addListener("close", function (had_error) {
+    //puts("server had_error: " + JSON.stringify(had_error));
+    assert.equal(false, had_error);
+  });
+});
+
+server.listen(PORT, function () {
+  puts('listening');
+  var client = net.createConnection(PORT);
+
+  client.setEncoding("UTF8");
+
+  client.addListener("connect", function () {
+    puts("client connected.");
+  });
+
+  client.addListener("data", function (chunk) {
+    client_recv_count += 1;
+    puts("client_recv_count " + client_recv_count);
+    assert.equal("hello\r\n", chunk);
+    client.end();
+  });
+
+  client.addListener("close", function (had_error) {
+    puts("disconnect");
+    assert.equal(false, had_error);
+    if (disconnect_count++ < N)
+      client.connect(PORT); // reconnect
+    else
+      server.close();
+  });
+});
+
+process.addListener("exit", function () {
+  assert.equal(N+1, disconnect_count);
+  assert.equal(N+1, client_recv_count);
+});
+
diff --git a/test/simple/test-net-tls.js b/test/simple/test-net-tls.js
new file mode 100644 (file)
index 0000000..a5633d0
--- /dev/null
@@ -0,0 +1,96 @@
+require("../common");
+var fs = require('fs');
+var sys = require('sys');
+var net = require('net');
+
+var have_openssl;
+try {
+  var crypto = require('crypto');
+  have_openssl=true;
+} catch (e) {
+  have_openssl=false;
+  puts("Not compiled with OPENSSL support.");
+  process.exit();
+} 
+
+var caPem = fs.readFileSync(fixturesDir+"/test_ca.pem", 'ascii');
+var certPem = fs.readFileSync(fixturesDir+"/test_cert.pem", 'ascii');
+var keyPem = fs.readFileSync(fixturesDir+"/test_key.pem", 'ascii');
+
+var credentials = crypto.createCredentials({key:keyPem, cert:certPem, ca:caPem});
+
+var testData = "TEST123";
+var serverData = '';
+var clientData = '';
+var gotSecureServer = false;
+var gotSecureClient = false;
+
+var secureServer = net.createServer(function (connection) {
+  var self = this;
+  connection.setSecure(credentials);
+  connection.setEncoding("UTF8");
+
+  connection.addListener("secure", function () {
+    gotSecureServer = true;
+    var verified = connection.verifyPeer();
+    var peerDN = JSON.stringify(connection.getPeerCertificate());
+    assert.equal(verified, true);
+    assert.equal(peerDN, '{"subject":"/C=UK/ST=Acknack Ltd/L=Rhys Jones'
+                + '/O=node.js/OU=Test TLS Certificate/CN=localhost",'
+                + '"issuer":"/C=UK/ST=Acknack Ltd/L=Rhys Jones/O=node.js'
+                + '/OU=Test TLS Certificate/CN=localhost","valid_from":'
+                + '"Nov 11 09:52:22 2009 GMT","valid_to":'
+                + '"Nov  6 09:52:22 2029 GMT"}');
+
+  });
+
+  connection.addListener("data", function (chunk) {
+    serverData += chunk;
+    connection.write(chunk);
+  });
+
+  connection.addListener("end", function () {
+    assert.equal(serverData, testData);
+    connection.end();
+    self.close();
+  });
+});
+secureServer.listen(PORT);
+
+var secureClient = net.createConnection(PORT);
+
+secureClient.setEncoding("UTF8");
+secureClient.addListener("connect", function () {
+  secureClient.setSecure(credentials);
+});
+
+secureClient.addListener("secure", function () {
+  gotSecureClient = true;
+  var verified = secureClient.verifyPeer();
+  var peerDN = JSON.stringify(secureClient.getPeerCertificate());
+  assert.equal(verified, true);
+  assert.equal(peerDN, '{"subject":"/C=UK/ST=Acknack Ltd/L=Rhys Jones'
+                + '/O=node.js/OU=Test TLS Certificate/CN=localhost",'
+                + '"issuer":"/C=UK/ST=Acknack Ltd/L=Rhys Jones/O=node.js'
+                + '/OU=Test TLS Certificate/CN=localhost","valid_from":'
+                + '"Nov 11 09:52:22 2009 GMT","valid_to":'
+                + '"Nov  6 09:52:22 2029 GMT"}');
+
+  secureClient.write(testData);
+  secureClient.end();
+});
+
+secureClient.addListener("data", function (chunk) {
+  clientData += chunk;
+});
+
+secureClient.addListener("end", function () {
+  assert.equal(clientData, testData);
+});
+
+process.addListener("exit", function () {
+  assert.ok(gotSecureServer, "Did not get secure event for server");
+  assert.ok(gotSecureClient, "Did not get secure event for clientr");
+});
+
+
diff --git a/test/simple/test-tcp-binary.js b/test/simple/test-tcp-binary.js
deleted file mode 100644 (file)
index 9dc347a..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-require("../common");
-tcp = require("tcp");
-
-binaryString = "";
-for (var i = 255; i >= 0; i--) {
-  var s = "'\\" + i.toString(8) + "'";
-  S = eval(s);
-  error( s
-       + " "
-       + JSON.stringify(S)
-       + " "
-       + JSON.stringify(String.fromCharCode(i)) 
-       + " "
-       + S.charCodeAt(0)
-       );
-  process.assert(S.charCodeAt(0) == i);
-  process.assert(S == String.fromCharCode(i));
-  binaryString += S;
-}
-
-var echoServer = tcp.createServer(function (connection) {
-  connection.setEncoding("binary");
-  connection.addListener("data", function (chunk) {
-    error("recved: " + JSON.stringify(chunk));
-    connection.write(chunk, "binary");
-  });
-  connection.addListener("end", function () {
-    connection.end();
-  });
-});
-echoServer.listen(PORT);
-
-var recv = "";
-var j = 0;
-
-var c = tcp.createConnection(PORT);
-
-c.setEncoding("binary");
-c.addListener("data", function (chunk) {
-  if (j < 256) {
-    error("write " + j);
-    c.write(String.fromCharCode(j), "binary");
-    j++;
-  } else {
-    c.end();
-  }
-  recv += chunk;
-});
-
-c.addListener("connect", function () {
-  c.write(binaryString, "binary");
-});
-
-c.addListener("close", function () {
-  p(recv);
-  echoServer.close();
-});
-
-process.addListener("exit", function () {
-  puts("recv: " + JSON.stringify(recv));
-
-  assert.equal(2*256, recv.length);
-
-  var a = recv.split("");
-
-  var first = a.slice(0,256).reverse().join("");
-  puts("first: " + JSON.stringify(first));
-
-  var second = a.slice(256,2*256).join("");
-  puts("second: " + JSON.stringify(second));
-
-  assert.equal(first, second);
-});
diff --git a/test/simple/test-tcp-keepalive.js b/test/simple/test-tcp-keepalive.js
deleted file mode 100644 (file)
index adf5326..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-require("../common");
-net = require('net');
-
-var serverConnection;
-var echoServer = net.createServer(function (connection) {
-  serverConnection = connection;
-  connection.setTimeout(0);
-  assert.notEqual(connection.setKeepAlive,undefined);
-  // send a keepalive packet after 1000 ms
-  connection.setKeepAlive(true,1000);
-  connection.addListener("end", function () {
-    connection.end();
-  });
-});
-echoServer.listen(PORT);
-
-var clientConnection = net.createConnection(PORT);
-clientConnection.setTimeout(0);
-
-setTimeout( function() {
-  // make sure both connections are still open
-  assert.equal(serverConnection.readyState,"open");
-  assert.equal(clientConnection.readyState,"open");
-  serverConnection.end();
-  clientConnection.end();
-  echoServer.close();
-}, 1200);
-
diff --git a/test/simple/test-tcp-reconnect.js b/test/simple/test-tcp-reconnect.js
deleted file mode 100644 (file)
index 9b297a7..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-require("../common");
-net = require('net');
-var N = 50;
-
-var c = 0;
-var client_recv_count = 0;
-var disconnect_count = 0;
-
-var server = net.createServer(function (socket) {
-  socket.addListener("connect", function () {
-    socket.write("hello\r\n");
-  });
-
-  socket.addListener("end", function () {
-    socket.end();
-  });
-
-  socket.addListener("close", function (had_error) {
-    //puts("server had_error: " + JSON.stringify(had_error));
-    assert.equal(false, had_error);
-  });
-});
-
-server.listen(PORT, function () {
-  puts('listening');
-  var client = net.createConnection(PORT);
-
-  client.setEncoding("UTF8");
-
-  client.addListener("connect", function () {
-    puts("client connected.");
-  });
-
-  client.addListener("data", function (chunk) {
-    client_recv_count += 1;
-    puts("client_recv_count " + client_recv_count);
-    assert.equal("hello\r\n", chunk);
-    client.end();
-  });
-
-  client.addListener("close", function (had_error) {
-    puts("disconnect");
-    assert.equal(false, had_error);
-    if (disconnect_count++ < N)
-      client.connect(PORT); // reconnect
-    else
-      server.close();
-  });
-});
-
-process.addListener("exit", function () {
-  assert.equal(N+1, disconnect_count);
-  assert.equal(N+1, client_recv_count);
-});
-
diff --git a/test/simple/test-tcp-tls.js b/test/simple/test-tcp-tls.js
deleted file mode 100644 (file)
index a5633d0..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-require("../common");
-var fs = require('fs');
-var sys = require('sys');
-var net = require('net');
-
-var have_openssl;
-try {
-  var crypto = require('crypto');
-  have_openssl=true;
-} catch (e) {
-  have_openssl=false;
-  puts("Not compiled with OPENSSL support.");
-  process.exit();
-} 
-
-var caPem = fs.readFileSync(fixturesDir+"/test_ca.pem", 'ascii');
-var certPem = fs.readFileSync(fixturesDir+"/test_cert.pem", 'ascii');
-var keyPem = fs.readFileSync(fixturesDir+"/test_key.pem", 'ascii');
-
-var credentials = crypto.createCredentials({key:keyPem, cert:certPem, ca:caPem});
-
-var testData = "TEST123";
-var serverData = '';
-var clientData = '';
-var gotSecureServer = false;
-var gotSecureClient = false;
-
-var secureServer = net.createServer(function (connection) {
-  var self = this;
-  connection.setSecure(credentials);
-  connection.setEncoding("UTF8");
-
-  connection.addListener("secure", function () {
-    gotSecureServer = true;
-    var verified = connection.verifyPeer();
-    var peerDN = JSON.stringify(connection.getPeerCertificate());
-    assert.equal(verified, true);
-    assert.equal(peerDN, '{"subject":"/C=UK/ST=Acknack Ltd/L=Rhys Jones'
-                + '/O=node.js/OU=Test TLS Certificate/CN=localhost",'
-                + '"issuer":"/C=UK/ST=Acknack Ltd/L=Rhys Jones/O=node.js'
-                + '/OU=Test TLS Certificate/CN=localhost","valid_from":'
-                + '"Nov 11 09:52:22 2009 GMT","valid_to":'
-                + '"Nov  6 09:52:22 2029 GMT"}');
-
-  });
-
-  connection.addListener("data", function (chunk) {
-    serverData += chunk;
-    connection.write(chunk);
-  });
-
-  connection.addListener("end", function () {
-    assert.equal(serverData, testData);
-    connection.end();
-    self.close();
-  });
-});
-secureServer.listen(PORT);
-
-var secureClient = net.createConnection(PORT);
-
-secureClient.setEncoding("UTF8");
-secureClient.addListener("connect", function () {
-  secureClient.setSecure(credentials);
-});
-
-secureClient.addListener("secure", function () {
-  gotSecureClient = true;
-  var verified = secureClient.verifyPeer();
-  var peerDN = JSON.stringify(secureClient.getPeerCertificate());
-  assert.equal(verified, true);
-  assert.equal(peerDN, '{"subject":"/C=UK/ST=Acknack Ltd/L=Rhys Jones'
-                + '/O=node.js/OU=Test TLS Certificate/CN=localhost",'
-                + '"issuer":"/C=UK/ST=Acknack Ltd/L=Rhys Jones/O=node.js'
-                + '/OU=Test TLS Certificate/CN=localhost","valid_from":'
-                + '"Nov 11 09:52:22 2009 GMT","valid_to":'
-                + '"Nov  6 09:52:22 2029 GMT"}');
-
-  secureClient.write(testData);
-  secureClient.end();
-});
-
-secureClient.addListener("data", function (chunk) {
-  clientData += chunk;
-});
-
-secureClient.addListener("end", function () {
-  assert.equal(clientData, testData);
-});
-
-process.addListener("exit", function () {
-  assert.ok(gotSecureServer, "Did not get secure event for server");
-  assert.ok(gotSecureClient, "Did not get secure event for clientr");
-});
-
-