Skip to content

Commit df17c62

Browse files
AdamMajertargos
authored andcommitted
test: use localhost test instead of connecting to remote
Fixes: #39008 PR-URL: #39011 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: Zijian Liu <[email protected]>
1 parent 35331cb commit df17c62

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

‎test/parallel/test-https-agent-unref-socket.js‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,24 @@ if (!common.hasCrypto)
66

77
consthttps=require('https');
88

9-
constrequest=https.get('https://example.com');
9+
if(process.argv[2]==='localhost'){
10+
constrequest=https.get('https://localhost:'+process.argv[3]);
1011

11-
request.on('socket',(socket)=>{
12-
socket.unref();
13-
});
12+
request.on('socket',(socket)=>{
13+
socket.unref();
14+
});
15+
}else{
16+
constassert=require('assert');
17+
constnet=require('net');
18+
constserver=net.createServer();
19+
server.listen(0);
20+
server.on('listening',()=>{
21+
constport=server.address().port;
22+
const{ fork }=require('child_process');
23+
constchild=fork(__filename,['localhost',port],{});
24+
child.on('close',(exit_code)=>{
25+
server.close();
26+
assert.strictEqual(exit_code,0);
27+
});
28+
});
29+
}

0 commit comments

Comments
(0)