Skip to content

Commit

Permalink
test: refactor test-tls-securepair-fiftharg
Browse files Browse the repository at this point in the history
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: #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>
  • Loading branch information
addaleax authored and MylesBorins committed Feb 13, 2018
1 parent 32f528a commit b3e625d
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions test/parallel/test-tls-securepair-fiftharg.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,13 @@ 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');
})
});

// captured traffic from browser's request to https://www.google.com
const sslHello = fixtures.readSync('google_ssl_hello.bin');

pair.encrypted.write(sslHello);

process.on('exit', function() {
assert.strictEqual('www.google.com', catchedServername);
});

0 comments on commit b3e625d

Please sign in to comment.