test: Use common.mustCall in http test

PR-URL: https://github.com/nodejs/node/pull/17487
Refs: https://github.com/nodejs/node/issues/17169
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
This commit is contained in:
sreepurnajasti 2017-12-06 17:02:41 +05:30 committed by Anatoli Papirovski
parent 4e65f9d504
commit f81bb7b527
No known key found for this signature in database
GPG Key ID: 614E2E1ABEB4B2C0

View File

@ -1,25 +1,20 @@
'use strict';
require('../common');
const assert = require('assert');
const common = require('../common');
const http = require('http');
const net = require('net');
const COUNT = 10;
let received = 0;
const server = http.createServer(function(req, res) {
const server = http.createServer(common.mustCall((req, res) => {
// Close the server, we have only one TCP connection anyway
if (received++ === 0)
server.close();
server.close();
res.writeHead(200);
res.write('data');
setTimeout(function() {
res.end();
}, (Math.random() * 100) | 0);
}).listen(0, function() {
}, COUNT)).listen(0, function() {
const s = net.connect(this.address().port);
const big = 'GET / HTTP/1.0\r\n\r\n'.repeat(COUNT);
@ -27,7 +22,3 @@ const server = http.createServer(function(req, res) {
s.write(big);
s.resume();
});
process.on('exit', function() {
assert.strictEqual(received, COUNT);
});