Permalink
Browse files

test: improve code in test-crypto-verify

* use common.mustCall to validate functions executions
* use common.fail to check test fail
* remove console.log
* use arrow functions

PR-URL: #10845
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
edsadr authored and sam-github committed Jan 20, 2017
1 parent b4b37e8 commit 8ab561b2432bdae39b1e8da723d47c95c9d6afaa
Showing with 12 additions and 16 deletions.
  1. +12 −16 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();

0 comments on commit 8ab561b

Please sign in to comment.