Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix nits in test/fixtures/tls-connect.js #28880

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions test/fixtures/tls-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports.debug = util.debuglog('test');
exports.tls = tls;

// Pre-load keys from common fixtures for ease of use by tests.
const keys = exports.keys = {
exports.keys = {
agent1: load('agent1', 'ca1'),
agent2: load('agent2', 'agent2'),
agent3: load('agent3', 'ca2'),
Expand All @@ -31,9 +31,9 @@ const keys = exports.keys = {
ec: load('ec', 'ec'),
};

// root is the self-signed root of the trust chain, not an intermediate ca.
// `root` is the self-signed root of the trust chain, not an intermediate ca.
function load(cert, root) {
root = root || cert; // Assume self-signed if no issuer
root = root || cert; // Assume self-signed if no issuer.
const id = {
key: fixtures.readKey(cert + '-key.pem', 'binary'),
cert: fixtures.readKey(cert + '-cert.pem', 'binary'),
Expand All @@ -53,7 +53,7 @@ exports.connect = function connect(options, callback) {
tls.createServer(options.server, function(conn) {
server.conn = conn;
conn.pipe(conn);
maybeCallback()
maybeCallback();
}).listen(0, function() {
server.server = this;

Expand Down Expand Up @@ -92,7 +92,7 @@ exports.connect = function connect(options, callback) {
function maybeCallback() {
if (!callback)
return;
if (server.conn && (client.conn || client.err)) {
Copy link
Member Author

@lpinca lpinca Jul 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client.err is set by the 'error' listener of the client socket or in the catch branch of the try...catch around tls.connect(). In the latter case maybeCallback() is not used as the callback is called directly. In the former client.conn is also set.

if (server.conn && client.conn) {
const err = pair.client.err || pair.server.err;
callback(err, pair, cleanup);
callback = null;
Expand All @@ -105,4 +105,4 @@ exports.connect = function connect(options, callback) {
if (client.conn)
client.conn.end();
}
}
};