Skip to content

Commit d3c85a4

Browse files
TrottMylesBorins
authored andcommitted
test: refactor test-tls-invoked-queued
* use common.mustCall()/common.mustNotCall() as appropriate * reorder require() statements per test writing guide * add comment PR-URL: #13893 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 676a94e commit d3c85a4

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

test/parallel/test-tls-invoke-queued.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
'use strict';
22
const common = require('../common');
3-
const assert = require('assert');
43

54
if (!common.hasCrypto) {
65
common.skip('missing crypto');
76
return;
87
}
9-
const tls = require('tls');
108

9+
const assert = require('assert');
1110
const fs = require('fs');
12-
11+
const tls = require('tls');
1312

1413
let received = '';
1514

1615
const server = tls.createServer({
1716
key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`),
1817
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`)
19-
}, function(c) {
20-
c._write('hello ', null, function() {
21-
c._write('world!', null, function() {
18+
}, common.mustCall(function(c) {
19+
c._write('hello ', null, common.mustCall(function() {
20+
c._write('world!', null, common.mustCall(function() {
2221
c.destroy();
23-
});
24-
c._write(' gosh', null, common.noop);
25-
});
22+
}));
23+
// Data on next _write() will be written but callback will not be invoked
24+
c._write(' gosh', null, common.mustNotCall());
25+
}));
2626

2727
server.close();
28-
}).listen(0, common.mustCall(function() {
28+
})).listen(0, common.mustCall(function() {
2929
const c = tls.connect(this.address().port, {
3030
rejectUnauthorized: false
3131
}, common.mustCall(function() {

0 commit comments

Comments
 (0)