diff --git a/test/pummel/test-net-timeout.js b/test/pummel/test-net-timeout.js index c7b6764d88..a02540e813 100644 --- a/test/pummel/test-net-timeout.js +++ b/test/pummel/test-net-timeout.js @@ -32,44 +32,44 @@ var echo_server = net.createServer(function (socket) { echo_server.listen(common.PORT, function () { console.log("server listening at " + common.PORT); -}); -var client = net.createConnection(common.PORT); -client.setEncoding("UTF8"); -client.setTimeout(0); // disable the timeout for client -client.addListener("connect", function () { - console.log("client connected."); - client.write("hello\r\n"); -}); + var client = net.createConnection(common.PORT); + client.setEncoding("UTF8"); + client.setTimeout(0); // disable the timeout for client + client.addListener("connect", function () { + console.log("client connected."); + client.write("hello\r\n"); + }); -client.addListener("data", function (chunk) { - assert.equal("hello\r\n", chunk); - if (exchanges++ < 5) { - setTimeout(function () { - console.log("client write 'hello'"); - client.write("hello\r\n"); - }, 500); - - if (exchanges == 5) { - console.log("wait for timeout - should come in " + timeout + " ms"); - starttime = new Date; - console.dir(starttime); + client.addListener("data", function (chunk) { + assert.equal("hello\r\n", chunk); + if (exchanges++ < 5) { + setTimeout(function () { + console.log("client write 'hello'"); + client.write("hello\r\n"); + }, 500); + + if (exchanges == 5) { + console.log("wait for timeout - should come in " + timeout + " ms"); + starttime = new Date; + console.dir(starttime); + } } - } -}); + }); -client.addListener("timeout", function () { - throw new Error("client timeout - this shouldn't happen"); -}); + client.addListener("timeout", function () { + throw new Error("client timeout - this shouldn't happen"); + }); -client.addListener("end", function () { - console.log("client end"); - client.end(); -}); + client.addListener("end", function () { + console.log("client end"); + client.end(); + }); -client.addListener("close", function () { - console.log("client disconnect"); - echo_server.close(); + client.addListener("close", function () { + console.log("client disconnect"); + echo_server.close(); + }); }); process.addListener("exit", function () { diff --git a/test/simple/test-http-client-parse-error.js b/test/simple/test-http-client-parse-error.js index f3a4497c9e..d598b31d51 100644 --- a/test/simple/test-http-client-parse-error.js +++ b/test/simple/test-http-client-parse-error.js @@ -12,18 +12,19 @@ var srv = net.createServer(function(c) { c.addListener('end', function() { c.end(); }); }); -srv.listen(common.PORT, '127.0.0.1'); - -var hc = http.createClient(common.PORT, '127.0.0.1'); -hc.request('GET', '/').end(); var parseError = false; -hc.on('error', function (e) { - console.log("got error from client"); - srv.close(); - assert.ok(e.message.indexOf("Parse Error") >= 0); - parseError = true; +srv.listen(common.PORT, '127.0.0.1', function () { + var hc = http.createClient(common.PORT, '127.0.0.1'); + hc.request('GET', '/').end(); + + hc.on('error', function (e) { + console.log("got error from client"); + srv.close(); + assert.ok(e.message.indexOf("Parse Error") >= 0); + parseError = true; + }); });