Skip to content

Commit eb7ee50

Browse files
edsadritaloacasas
authored andcommitted
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 <[email protected]> Reviewed-By: Sam Roberts <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent efa9845 commit eb7ee50

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

test/parallel/test-crypto-verify-failure.js

+12-16
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,32 @@ const options = {
1919
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
2020
};
2121

22-
const server = tls.Server(options, function(socket) {
23-
setImmediate(function() {
24-
console.log('sending');
22+
const server = tls.Server(options, (socket) => {
23+
setImmediate(() => {
2524
verify();
26-
setImmediate(function() {
25+
setImmediate(() => {
2726
socket.destroy();
2827
});
2928
});
3029
});
3130

3231
function verify() {
33-
console.log('verify');
3432
crypto.createVerify('RSA-SHA1')
3533
.update('Test')
3634
.verify(certPem, 'asdfasdfas', 'base64');
3735
}
3836

39-
server.listen(0, function() {
37+
server.listen(0, common.mustCall(() => {
4038
tls.connect({
41-
port: this.address().port,
39+
port: server.address().port,
4240
rejectUnauthorized: false
43-
}, function() {
41+
}, common.mustCall(() => {
4442
verify();
45-
}).on('data', function(data) {
46-
console.log(data);
47-
}).on('error', function(err) {
48-
throw err;
49-
}).on('close', function() {
50-
server.close();
51-
}).resume();
52-
});
43+
}))
44+
.on('error', common.fail)
45+
.on('close', common.mustCall(() => {
46+
server.close();
47+
})).resume();
48+
}));
5349

5450
server.unref();

0 commit comments

Comments
 (0)