Skip to content
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
test: make test-tls-connect checks more strict
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.
  • Loading branch information
Trott committed Aug 8, 2017
commit e476b6d61c5d33887c2ee233d86460ab2401325a
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'); })
);
}