Skip to content

Commit 1be8676

Browse files
sam-githubaddaleax
authored andcommitted
test: use mustCall(), not global state checks
Instead of pushing state into global arrays and checking the results before exit, use common.mustCall() and make the checks immediately. PR-URL: #25508 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 50d2c8e commit 1be8676

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

test/parallel/test-tls-socket-constructor-alpn-options-parsing.js

+4-13
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ const fixtures = require('../common/fixtures');
2020
const key = fixtures.readKey('agent1-key.pem');
2121
const cert = fixtures.readKey('agent1-cert.pem');
2222

23-
const protocols = [];
24-
2523
const server = net.createServer(common.mustCall((s) => {
2624
const tlsSocket = new tls.TLSSocket(s, {
2725
isServer: true,
@@ -32,10 +30,9 @@ const server = net.createServer(common.mustCall((s) => {
3230
});
3331

3432
tlsSocket.on('secure', common.mustCall(() => {
35-
protocols.push({
36-
alpnProtocol: tlsSocket.alpnProtocol,
37-
});
33+
assert.strictEqual(tlsSocket.alpnProtocol, 'http/1.1');
3834
tlsSocket.end();
35+
server.close();
3936
}));
4037
}));
4138

@@ -46,13 +43,7 @@ server.listen(0, common.mustCall(() => {
4643
ALPNProtocols: ['h2', 'http/1.1']
4744
};
4845

49-
tls.connect(alpnOpts, function() {
46+
tls.connect(alpnOpts, common.mustCall(function() {
5047
this.end();
51-
52-
server.close();
53-
54-
assert.deepStrictEqual(protocols, [
55-
{ alpnProtocol: 'http/1.1' },
56-
]);
57-
});
48+
}));
5849
}));

0 commit comments

Comments
 (0)