Skip to content

Commit

Permalink
test: improve test-net-pingpong
Browse files Browse the repository at this point in the history
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: #2429
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
brendanashworth authored and rvagg committed Aug 20, 2015
1 parent 3e6a6fc commit 11d1b8f
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions test/parallel/test-net-pingpong.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -73,8 +70,6 @@ function pingPongTest(port, host) {
});

client.on('data', function(data) {
console.log('client got: ' + data);

assert.equal('PONG', data);
count += 1;

Expand Down

0 comments on commit 11d1b8f

Please sign in to comment.