Skip to content

Commit

Permalink
test: improve code in test-crypto-verify
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
Reviewed-By: Sam Roberts <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
edsadr authored and italoacasas committed Jan 30, 2017
1 parent efa9845 commit eb7ee50
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions test/parallel/test-crypto-verify-failure.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 eb7ee50

Please sign in to comment.