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
  • Loading branch information
edsadr committed Jan 20, 2017
1 parent 762f260 commit 67b920d
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 67b920d

Please sign in to comment.