Skip to content

Commit 11d1b8f

Browse files
brendanashworthrvagg
authored andcommitted
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: #2429 Reviewed-By: Rich Trott <[email protected]>
1 parent 3e6a6fc commit 11d1b8f

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

test/parallel/test-net-pingpong.js

+5-10
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,17 @@ function pingPongTest(port, host) {
2727
// than one message.
2828
assert.ok(0 <= socket.bufferSize && socket.bufferSize <= 4);
2929

30-
console.log('server got: ' + data);
3130
assert.equal(true, socket.writable);
3231
assert.equal(true, socket.readable);
3332
assert.equal(true, count <= N);
34-
if (/PING/.exec(data)) {
35-
socket.write('PONG', function() {
36-
sentPongs++;
37-
console.error('sent PONG');
38-
});
39-
}
33+
assert.equal(data, 'PING');
34+
35+
socket.write('PONG', function() {
36+
sentPongs++;
37+
});
4038
});
4139

4240
socket.on('end', function() {
43-
console.error(socket);
4441
assert.equal(true, socket.allowHalfOpen);
4542
assert.equal(true, socket.writable); // because allowHalfOpen
4643
assert.equal(false, socket.readable);
@@ -73,8 +70,6 @@ function pingPongTest(port, host) {
7370
});
7471

7572
client.on('data', function(data) {
76-
console.log('client got: ' + data);
77-
7873
assert.equal('PONG', data);
7974
count += 1;
8075

0 commit comments

Comments
 (0)