Skip to content

Commit

Permalink
test: make test-tls-connect checks more strict
Browse files Browse the repository at this point in the history
Check the error code on expected errors so that the introduction of
different errors in refactoring is caught.

While at it, re-order modules alphabetically per test-writing guide.

PR-URL: #14695
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
Trott authored and addaleax committed Aug 12, 2017
1 parent c5ee34e commit 977e228
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions test/parallel/test-tls-connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const tls = require('tls');
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const tls = require('tls');

// https://github.com/joyent/node/issues/1218
// uncatchable exception on TLS connection error
Expand All @@ -38,7 +39,10 @@ const path = require('path');
const options = {cert: cert, key: key, port: common.PORT};
const conn = tls.connect(options, common.mustNotCall());

conn.on('error', common.mustCall());
conn.on(
'error',
common.mustCall((e) => { assert.strictEqual(e.code, 'ECONNREFUSED'); })
);
}

// SSL_accept/SSL_connect error handling
Expand All @@ -53,5 +57,8 @@ const path = require('path');
ciphers: 'rick-128-roll'
}, common.mustNotCall());

conn.on('error', common.mustCall());
conn.on(
'error',
common.mustCall((e) => { assert.strictEqual(e.code, 'ECONNREFUSED'); })
);
}

0 comments on commit 977e228

Please sign in to comment.