test: refactor test-tls-securepair-fiftharg

Assert the server name directly in the `SNICallback`,
since `common.mustCall()` already guarantees that the callback
is called exactly once, making `process.on('exit')` unnecessary.

PR-URL: https://github.com/nodejs/node/pull/17836
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Anna Henningsen 2017-12-23 09:00:43 +01:00
parent 46510f54be
commit b34367150e
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9

View File

@ -13,10 +13,9 @@ const sslcontext = tls.createSecureContext({
key: fixtures.readSync('test_key.pem')
});
let catchedServername;
const pair = tls.createSecurePair(sslcontext, true, false, false, {
SNICallback: common.mustCall(function(servername, cb) {
catchedServername = servername;
SNICallback: common.mustCall((servername, cb) => {
assert.strictEqual(servername, 'www.google.com');
})
});
@ -24,7 +23,3 @@ const pair = tls.createSecurePair(sslcontext, true, false, false, {
const sslHello = fixtures.readSync('google_ssl_hello.bin');
pair.encrypted.write(sslHello);
process.on('exit', function() {
assert.strictEqual('www.google.com', catchedServername);
});