mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
test: use localhost test instead of connecting to remote
Fixes: https://github.com/nodejs/node/issues/39008 PR-URL: https://github.com/nodejs/node/pull/39011 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
This commit is contained in:
parent
8a8c7f41e1
commit
520ad58658
@ -6,8 +6,24 @@ if (!common.hasCrypto)
|
||||
|
||||
const https = require('https');
|
||||
|
||||
const request = https.get('https://example.com');
|
||||
if (process.argv[2] === 'localhost') {
|
||||
const request = https.get('https://localhost:' + process.argv[3]);
|
||||
|
||||
request.on('socket', (socket) => {
|
||||
socket.unref();
|
||||
});
|
||||
request.on('socket', (socket) => {
|
||||
socket.unref();
|
||||
});
|
||||
} else {
|
||||
const assert = require('assert');
|
||||
const net = require('net');
|
||||
const server = net.createServer();
|
||||
server.listen(0);
|
||||
server.on('listening', () => {
|
||||
const port = server.address().port;
|
||||
const { fork } = require('child_process');
|
||||
const child = fork(__filename, ['localhost', port], {});
|
||||
child.on('close', (exit_code) => {
|
||||
server.close();
|
||||
assert.strictEqual(exit_code, 0);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user