mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 22:56:06 +00:00

Use assert.strictEqual instead of assert.equal in tests, manually convert types where necessary. PR-URL: https://github.com/nodejs/node/pull/10698 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
38 lines
852 B
JavaScript
38 lines
852 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
|
|
const big = Buffer.alloc(1024 * 1024);
|
|
|
|
const server = net.createServer((socket) => {
|
|
socket.end(big);
|
|
server.close();
|
|
}).listen(0, () => {
|
|
let prev = 0;
|
|
|
|
function checkRaise(value) {
|
|
assert(value > prev);
|
|
prev = value;
|
|
}
|
|
|
|
const socket = net.connect(server.address().port, () => {
|
|
socket.on('data', (chunk) => {
|
|
checkRaise(socket.bytesRead);
|
|
});
|
|
|
|
socket.on('end', common.mustCall(() => {
|
|
assert.strictEqual(socket.bytesRead, prev);
|
|
assert.strictEqual(big.length, prev);
|
|
}));
|
|
|
|
socket.on('close', common.mustCall(() => {
|
|
assert(!socket._handle);
|
|
assert.strictEqual(socket.bytesRead, prev);
|
|
assert.strictEqual(big.length, prev);
|
|
}));
|
|
});
|
|
socket.end();
|
|
});
|