test: refactor test-https-connect-localport
Use arrow functions for callbacks. Replace uses of `this` with explicit variables. Add a trailing comma in a multiline object literal declaration. PR-URL: https://github.com/nodejs/node/pull/26881 Fixes: https://github.com/https://github.com/nodejs/node/issues/26862 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
This commit is contained in:
parent
f5969f08a0
commit
4a40ea6894
@ -9,21 +9,23 @@ const https = require('https');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
{
|
{
|
||||||
https.createServer({
|
const server = https.createServer({
|
||||||
cert: fixtures.readKey('agent1-cert.pem'),
|
cert: fixtures.readKey('agent1-cert.pem'),
|
||||||
key: fixtures.readKey('agent1-key.pem'),
|
key: fixtures.readKey('agent1-key.pem'),
|
||||||
}, common.mustCall(function(req, res) {
|
}, common.mustCall((req, res) => {
|
||||||
this.close();
|
server.close();
|
||||||
res.end();
|
res.end();
|
||||||
})).listen(0, 'localhost', common.mustCall(function() {
|
}));
|
||||||
const port = this.address().port;
|
|
||||||
|
server.listen(0, 'localhost', common.mustCall(() => {
|
||||||
|
const port = server.address().port;
|
||||||
const req = https.get({
|
const req = https.get({
|
||||||
host: 'localhost',
|
host: 'localhost',
|
||||||
pathname: '/',
|
pathname: '/',
|
||||||
port,
|
port,
|
||||||
family: 4,
|
family: 4,
|
||||||
localPort: common.PORT,
|
localPort: common.PORT,
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false,
|
||||||
}, common.mustCall(() => {
|
}, common.mustCall(() => {
|
||||||
assert.strictEqual(req.socket.localPort, common.PORT);
|
assert.strictEqual(req.socket.localPort, common.PORT);
|
||||||
assert.strictEqual(req.socket.remotePort, port);
|
assert.strictEqual(req.socket.remotePort, port);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user