Skip to content

Commit ecec11b

Browse files
committed
add support for all node versions
1 parent 3727ff4 commit ecec11b

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

test/ca.spec.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import { expect, fetch, ignoreNetworkError, nodeOnly } from "./test-utils";
77

88
import { CA, generateCACertificate } from '../src/util/tls';
99

10+
const nodeMajorVersion = parseInt(process.versions.node.split('.')[0], 10);
11+
1012
nodeOnly(() => {
11-
describe("Certificate generation", () => {
13+
describe.only("Certificate generation", () => {
1214
const caKey = fs.readFile(path.join(__dirname, 'fixtures', 'test-ca.key'), 'utf8');
1315
const caCert = fs.readFile(path.join(__dirname, 'fixtures', 'test-ca.pem'), 'utf8');
1416

@@ -58,7 +60,11 @@ nodeOnly(() => {
5860
port: 4430,
5961
ca: [constrainedCaCert],
6062
lookup: (hostname, options, callback) => {
61-
callback(null, [{ address: "127.0.0.1", family: 4 }]);
63+
if (nodeMajorVersion <= 18) {
64+
callback(null, "127.0.0.1", 4);
65+
} else {
66+
callback(null, [{ address: "127.0.0.1", family: 4 }]);
67+
}
6268
},
6369
},
6470
(res) => {
@@ -90,7 +96,11 @@ nodeOnly(() => {
9096
port: 4430,
9197
ca: [constrainedCaCert],
9298
lookup: (hostname, options, callback) => {
93-
callback(null, [{ address: "127.0.0.1", family: 4 }]);
99+
if (nodeMajorVersion <= 18) {
100+
callback(null, "127.0.0.1", 4);
101+
} else {
102+
callback(null, [{ address: "127.0.0.1", family: 4 }]);
103+
}
94104
},
95105
},
96106
);

0 commit comments

Comments
 (0)