Browse Source

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 <rtrott@gmail.com>
v4.0.0-rc
Brendan Ashworth 10 years ago
parent
commit
04722d14ca
  1. 15
      test/parallel/test-net-pingpong.js

15
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;

Loading…
Cancel
Save