From 876966f9c377d9dabdfda9241531b92bc39686dc Mon Sep 17 00:00:00 2001 From: Mithun Sasidharan Date: Sun, 3 Dec 2017 20:43:01 +0530 Subject: [PATCH] test: use common.mustCall in test-http-malformed-request MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/17439 Reviewed-By: Anatoli Papirovski Reviewed-By: Jon Moss Reviewed-By: Tobias Nießen Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-http-malformed-request.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/test/parallel/test-http-malformed-request.js b/test/parallel/test-http-malformed-request.js index 59816b513b3af7..781c629bfacd17 100644 --- a/test/parallel/test-http-malformed-request.js +++ b/test/parallel/test-http-malformed-request.js @@ -20,27 +20,22 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); -const assert = require('assert'); +const common = require('../common'); const net = require('net'); const http = require('http'); const url = require('url'); // Make sure no exceptions are thrown when receiving malformed HTTP // requests. - -let nrequests_completed = 0; -const nrequests_expected = 1; - -const server = http.createServer(function(req, res) { +const server = http.createServer(common.mustCall((req, res) => { console.log(`req: ${JSON.stringify(url.parse(req.url))}`); res.writeHead(200, { 'Content-Type': 'text/plain' }); res.write('Hello World'); res.end(); - if (++nrequests_completed === nrequests_expected) server.close(); -}); + server.close(); +})); server.listen(0); server.on('listening', function() { @@ -50,7 +45,3 @@ server.on('listening', function() { c.end(); }); }); - -process.on('exit', function() { - assert.strictEqual(nrequests_expected, nrequests_completed); -});