test: make test-tls-connect checks more strict · nodejs/node@91649b9

Original file line numberDiff line numberDiff line change

@@ -1,13 +1,13 @@

11

'use strict';

22

const common = require('../common');

3-

const assert = require('assert');

43
54

if (!common.hasCrypto)

65

common.skip('missing crypto');

76
8-

const tls = require('tls');

7+

const assert = require('assert');

98

const fs = require('fs');

109

const path = require('path');

10+

const tls = require('tls');

1111
1212

// https://github.com/joyent/node/issues/1218

1313

// uncatchable exception on TLS connection error

@@ -18,7 +18,10 @@ const path = require('path');

1818

const options = {cert: cert, key: key, port: common.PORT};

1919

const conn = tls.connect(options, common.fail);

2020
21-

conn.on('error', common.mustCall());

21+

conn.on(

22+

'error',

23+

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

24+

);

2225

}

2326
2427

// SSL_accept/SSL_connect error handling

@@ -35,5 +38,8 @@ const path = require('path');

3538

assert.ok(false); // callback should never be executed

3639

});

3740
38-

conn.on('error', common.mustCall());

41+

conn.on(

42+

'error',

43+

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

44+

);

3945

}