Skip to content

Commit af8e27d

Browse files
sreepurnajastiMylesBorins
authored andcommitted
test: Use common.mustCall in http test
PR-URL: #17487 Refs: #17169 Reviewed-By: Jon Moss <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]>
1 parent 7f2764d commit af8e27d

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed
+4-13
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,24 @@
11
'use strict';
2-
require('../common');
3-
const assert = require('assert');
2+
const common = require('../common');
43
const http = require('http');
54
const net = require('net');
65

76
const COUNT = 10;
87

9-
let received = 0;
10-
11-
const server = http.createServer(function(req, res) {
8+
const server = http.createServer(common.mustCall((req, res) => {
129
// Close the server, we have only one TCP connection anyway
13-
if (received++ === 0)
14-
server.close();
15-
10+
server.close();
1611
res.writeHead(200);
1712
res.write('data');
1813

1914
setTimeout(function() {
2015
res.end();
2116
}, (Math.random() * 100) | 0);
22-
}).listen(0, function() {
17+
}, COUNT)).listen(0, function() {
2318
const s = net.connect(this.address().port);
2419

2520
const big = 'GET / HTTP/1.0\r\n\r\n'.repeat(COUNT);
2621

2722
s.write(big);
2823
s.resume();
2924
});
30-
31-
process.on('exit', function() {
32-
assert.strictEqual(received, COUNT);
33-
});

0 commit comments

Comments
 (0)