node/test/parallel/test-net-large-string.js
Gibson Fahnestock 7a0e462f9f test: use eslint to fix var->const/let
Manually fix issues that eslint --fix couldn't do automatically.

PR-URL: https://github.com/nodejs/node/pull/10685
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2017-01-11 11:43:52 +00:00

31 lines
736 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const net = require('net');
const kPoolSize = 40 * 1024;
const data = 'あ'.repeat(kPoolSize);
const encoding = 'UTF-8';
const server = net.createServer(common.mustCall(function(socket) {
let receivedSize = 0;
socket.setEncoding(encoding);
socket.on('data', function(data) {
receivedSize += data.length;
});
socket.on('end', common.mustCall(function() {
assert.strictEqual(receivedSize, kPoolSize);
socket.end();
}));
}));
server.listen(0, function() {
const client = net.createConnection(this.address().port);
client.on('end', function() {
server.close();
});
client.write(data, encoding);
client.end();
});