From 11d1b8fcaf47b30c7126a37c8d548bad51f721b2 Mon Sep 17 00:00:00 2001 From: Brendan Ashworth Date: Tue, 18 Aug 2015 11:11:28 -0700 Subject: [PATCH] test: improve test-net-pingpong This includes the following changes: - a more strict data check rather than a regex - reduced number of annoying log calls The most important of the changes is the annoying log calls, which speeds up the test execution from about 0m1.130s to 0m0.481s on my machine. PR-URL: https://github.com/nodejs/node/pull/2429 Reviewed-By: Rich Trott --- test/parallel/test-net-pingpong.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/test/parallel/test-net-pingpong.js b/test/parallel/test-net-pingpong.js index 9a0c8af5b0697d..be7dfa435949b5 100644 --- a/test/parallel/test-net-pingpong.js +++ b/test/parallel/test-net-pingpong.js @@ -27,20 +27,17 @@ function pingPongTest(port, host) { // than one message. assert.ok(0 <= socket.bufferSize && socket.bufferSize <= 4); - console.log('server got: ' + data); assert.equal(true, socket.writable); assert.equal(true, socket.readable); assert.equal(true, count <= N); - if (/PING/.exec(data)) { - socket.write('PONG', function() { - sentPongs++; - console.error('sent PONG'); - }); - } + assert.equal(data, 'PING'); + + socket.write('PONG', function() { + sentPongs++; + }); }); socket.on('end', function() { - console.error(socket); assert.equal(true, socket.allowHalfOpen); assert.equal(true, socket.writable); // because allowHalfOpen assert.equal(false, socket.readable); @@ -73,8 +70,6 @@ function pingPongTest(port, host) { }); client.on('data', function(data) { - console.log('client got: ' + data); - assert.equal('PONG', data); count += 1;