Skip to content

Commit

Permalink
test: replace callback with arrow functions
Browse files Browse the repository at this point in the history
PR-URL: #24541
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
  • Loading branch information
sreepurnajasti authored and rvagg committed Nov 28, 2018
1 parent 0c51fc5 commit 4070152
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/pummel/test-net-throttle.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const body = 'C'.repeat(N);

console.log(`start server on port ${common.PORT}`);

const server = net.createServer(function(connection) {
const server = net.createServer((connection) => {
connection.write(body.slice(0, part_N));
connection.write(body.slice(part_N, 2 * part_N));
assert.strictEqual(connection.write(body.slice(2 * part_N, N)), false);
Expand All @@ -44,11 +44,11 @@ const server = net.createServer(function(connection) {
connection.end();
});

server.listen(common.PORT, function() {
server.listen(common.PORT, () => {
let paused = false;
const client = net.createConnection(common.PORT);
client.setEncoding('ascii');
client.on('data', function(d) {
client.on('data', (d) => {
chars_recved += d.length;
console.log(`got ${chars_recved}`);
if (!paused) {
Expand All @@ -57,7 +57,7 @@ server.listen(common.PORT, function() {
paused = true;
console.log('pause');
const x = chars_recved;
setTimeout(function() {
setTimeout(() => {
assert.strictEqual(chars_recved, x);
client.resume();
console.log('resume');
Expand All @@ -66,14 +66,14 @@ server.listen(common.PORT, function() {
}
});

client.on('end', function() {
client.on('end', () => {
server.close();
client.end();
});
});


process.on('exit', function() {
process.on('exit', () => {
assert.strictEqual(chars_recved, N);
assert.strictEqual(npauses > 2, true);
});

0 comments on commit 4070152

Please sign in to comment.