From 8ab561b2432bdae39b1e8da723d47c95c9d6afaa Mon Sep 17 00:00:00 2001 From: Adrian Estrada Date: Thu, 19 Jan 2017 20:40:33 -0500 Subject: [PATCH] test: improve code in test-crypto-verify MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * use common.mustCall to validate functions executions * use common.fail to check test fail * remove console.log * use arrow functions PR-URL: https://github.com/nodejs/node/pull/10845 Reviewed-By: Colin Ihrig Reviewed-By: Sam Roberts Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell --- test/parallel/test-crypto-verify-failure.js | 28 +++++++++------------ 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/test/parallel/test-crypto-verify-failure.js b/test/parallel/test-crypto-verify-failure.js index c171814dd3c3a6..fdf0d6f6456dac 100644 --- a/test/parallel/test-crypto-verify-failure.js +++ b/test/parallel/test-crypto-verify-failure.js @@ -19,36 +19,32 @@ const options = { cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -const server = tls.Server(options, function(socket) { - setImmediate(function() { - console.log('sending'); +const server = tls.Server(options, (socket) => { + setImmediate(() => { verify(); - setImmediate(function() { + setImmediate(() => { socket.destroy(); }); }); }); function verify() { - console.log('verify'); crypto.createVerify('RSA-SHA1') .update('Test') .verify(certPem, 'asdfasdfas', 'base64'); } -server.listen(0, function() { +server.listen(0, common.mustCall(() => { tls.connect({ - port: this.address().port, + port: server.address().port, rejectUnauthorized: false - }, function() { + }, common.mustCall(() => { verify(); - }).on('data', function(data) { - console.log(data); - }).on('error', function(err) { - throw err; - }).on('close', function() { - server.close(); - }).resume(); -}); + })) + .on('error', common.fail) + .on('close', common.mustCall(() => { + server.close(); + })).resume(); +})); server.unref();