Skip to content

Commit 021f7b8

Browse files
committedFeb 20, 2025
[test] Shorten the path lengths
Shorten the length of temporary file and UNIX domain socket paths. Refs: nodejs/node#57005 (comment)
1 parent b9ca55b commit 021f7b8

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed
 

‎test/websocket-server.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ describe('WebSocketServer', () => {
204204
});
205205

206206
it('uses a precreated http server listening on IPC', (done) => {
207-
const randomString = crypto.randomBytes(16).toString('hex');
207+
const randomString = crypto.randomBytes(4).toString('hex');
208208
const ipcPath =
209209
process.platform === 'win32'
210210
? `\\\\.\\pipe\\ws-pipe-${randomString}`

‎test/websocket.test.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ describe('WebSocket', () => {
664664
it("emits an 'error' event if an error occurs (2/2)", function (done) {
665665
if (!fs.openAsBlob) return this.skip();
666666

667-
const randomString = crypto.randomBytes(16).toString('hex');
667+
const randomString = crypto.randomBytes(4).toString('hex');
668668
const file = path.join(os.tmpdir(), `ws-${randomString}.txt`);
669669

670670
fs.writeFileSync(file, 'x'.repeat(64));
@@ -704,7 +704,7 @@ describe('WebSocket', () => {
704704
it("emits the 'error' event only once (1/2)", function (done) {
705705
if (!fs.openAsBlob) return this.skip();
706706

707-
const randomString = crypto.randomBytes(16).toString('hex');
707+
const randomString = crypto.randomBytes(4).toString('hex');
708708
const file = path.join(os.tmpdir(), `ws-${randomString}.txt`);
709709

710710
fs.writeFileSync(file, 'x'.repeat(64));
@@ -760,7 +760,7 @@ describe('WebSocket', () => {
760760
it("emits the 'error' event only once (2/2)", function (done) {
761761
if (!fs.openAsBlob) return this.skip();
762762

763-
const randomString = crypto.randomBytes(16).toString('hex');
763+
const randomString = crypto.randomBytes(4).toString('hex');
764764
const file = path.join(os.tmpdir(), `ws-${randomString}.txt`);
765765

766766
fs.writeFileSync(file, 'x'.repeat(64));
@@ -812,7 +812,7 @@ describe('WebSocket', () => {
812812
it("does not emit 'error' after 'close'", function (done) {
813813
if (!fs.openAsBlob) return this.skip();
814814

815-
const randomString = crypto.randomBytes(16).toString('hex');
815+
const randomString = crypto.randomBytes(4).toString('hex');
816816
const file = path.join(os.tmpdir(), `ws-${randomString}.bin`);
817817

818818
fs.writeFileSync(file, crypto.randomBytes(1024 * 1024));
@@ -1866,7 +1866,7 @@ describe('WebSocket', () => {
18661866
it('drops the Authorization, Cookie and Host headers (2/4)', (done) => {
18671867
// Test the `ws:` to `ws+unix:` case.
18681868

1869-
const randomString = crypto.randomBytes(16).toString('hex');
1869+
const randomString = crypto.randomBytes(4).toString('hex');
18701870
const ipcPath =
18711871
process.platform === 'win32'
18721872
? `\\\\.\\pipe\\ws-pipe-${randomString}`
@@ -1926,8 +1926,8 @@ describe('WebSocket', () => {
19261926
it('drops the Authorization, Cookie and Host headers (3/4)', (done) => {
19271927
// Test the `ws+unix:` to `ws+unix:` case.
19281928

1929-
const randomString1 = crypto.randomBytes(16).toString('hex');
1930-
const randomString2 = crypto.randomBytes(16).toString('hex');
1929+
const randomString1 = crypto.randomBytes(4).toString('hex');
1930+
const randomString2 = crypto.randomBytes(4).toString('hex');
19311931
let redirectingServerIpcPath;
19321932
let redirectedServerIpcPath;
19331933

@@ -2025,7 +2025,7 @@ describe('WebSocket', () => {
20252025
ws.close();
20262026
});
20272027

2028-
const randomString = crypto.randomBytes(16).toString('hex');
2028+
const randomString = crypto.randomBytes(4).toString('hex');
20292029
const ipcPath =
20302030
process.platform === 'win32'
20312031
? `\\\\.\\pipe\\ws-pipe-${randomString}`

0 commit comments

Comments
 (0)
Please sign in to comment.