Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 21153f1

Browse filesBrowse files
tniessentargos
authored andcommitted
test: simplify test-tls-ecdh-auto
Avoid the process 'exit' event handler and use execFile instead of manual stream operations. Refs: #46751 PR-URL: #46911 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
1 parent 762dc7c commit 21153f1
Copy full SHA for 21153f1

File tree

Expand file treeCollapse file tree

1 file changed

+8
-26
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-26
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-tls-ecdh-auto.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-tls-ecdh-auto.js
+8-26Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if (!common.opensslCli)
1212

1313
const assert = require('assert');
1414
const tls = require('tls');
15-
const spawn = require('child_process').spawn;
15+
const { execFile } = require('child_process');
1616
const fixtures = require('../common/fixtures');
1717

1818
function loadPEM(n) {
@@ -29,33 +29,15 @@ const options = {
2929

3030
const reply = 'I AM THE WALRUS'; // Something recognizable
3131

32-
const server = tls.createServer(options, function(conn) {
32+
const server = tls.createServer(options, (conn) => {
3333
conn.end(reply);
34-
});
35-
36-
let gotReply = false;
37-
38-
server.listen(0, function() {
34+
}).listen(0, common.mustCall(() => {
3935
const args = ['s_client',
4036
'-cipher', `${options.ciphers}`,
41-
'-connect', `127.0.0.1:${this.address().port}`];
42-
43-
const client = spawn(common.opensslCli, args);
37+
'-connect', `127.0.0.1:${server.address().port}`];
4438

45-
client.stdout.on('data', function(data) {
46-
const message = data.toString();
47-
if (message.includes(reply))
48-
gotReply = true;
49-
});
50-
51-
client.on('exit', function(code) {
52-
assert.strictEqual(code, 0);
39+
execFile(common.opensslCli, args, common.mustSucceed((stdout) => {
40+
assert(stdout.includes(reply));
5341
server.close();
54-
});
55-
56-
client.on('error', assert.ifError);
57-
});
58-
59-
process.on('exit', function() {
60-
assert.ok(gotReply);
61-
});
42+
}));
43+
}));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.