|
20 | 20 | // USE OR OTHER DEALINGS IN THE SOFTWARE. |
21 | 21 |
|
22 | 22 | 'use strict'; |
23 | | -require('../common'); |
| 23 | +const common = require('../common'); |
24 | 24 | const assert = require('assert'); |
25 | 25 | const net = require('net'); |
26 | 26 |
|
27 | | -const events = []; |
28 | 27 | const sockets = []; |
29 | 28 |
|
30 | | -process.on('exit', function() { |
31 | | - assert.strictEqual(server.connections, 0); |
32 | | - assert.strictEqual(events.length, 3); |
33 | | - // Expect to see one server event and two client events. The order of the |
34 | | - // events is undefined because they arrive on the same event loop tick. |
35 | | - assert.strictEqual(events.join(' ').match(/server/g).length, 1); |
36 | | - assert.strictEqual(events.join(' ').match(/client/g).length, 2); |
37 | | -}); |
38 | | - |
39 | 29 | const server = net.createServer(function(c) { |
40 | | - c.on('close', function() { |
41 | | - events.push('client'); |
42 | | - }); |
| 30 | + c.on('close', common.mustCall()); |
43 | 31 |
|
44 | 32 | sockets.push(c); |
45 | 33 |
|
46 | 34 | if (sockets.length === 2) { |
47 | 35 | assert.strictEqual(server.close(), server); |
48 | | - sockets.forEach(function(c) { c.destroy(); }); |
| 36 | + sockets.forEach((c) => c.destroy()); |
49 | 37 | } |
50 | 38 | }); |
51 | 39 |
|
52 | | -server.on('close', function() { |
53 | | - events.push('server'); |
54 | | -}); |
| 40 | +server.on('close', common.mustCall()); |
55 | 41 |
|
56 | | -assert.strictEqual(server, server.listen(0, function() { |
57 | | - net.createConnection(this.address().port); |
58 | | - net.createConnection(this.address().port); |
| 42 | +assert.strictEqual(server, server.listen(0, () => { |
| 43 | + net.createConnection(server.address().port); |
| 44 | + net.createConnection(server.address().port); |
59 | 45 | })); |
0 commit comments