Skip to content

Commit

Permalink
test: use localhost test instead of connecting to remote
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamMajer committed Jun 11, 2021
1 parent d615aeb commit 485a2db
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions test/parallel/test-https-agent-unref-socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 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();
if (exit_code == null || exit_code !== 0)
process.exit(1);
});
});
}

0 comments on commit 485a2db

Please sign in to comment.