Skip to content

Commit

Permalink
[test] Shorten the path lengths
Browse files Browse the repository at this point in the history
Shorten the length of temporary file and UNIX domain socket paths.

Refs: nodejs/node#57005 (comment)
  • Loading branch information
lpinca committed Feb 20, 2025
1 parent b9ca55b commit 021f7b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion test/websocket-server.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ describe('WebSocketServer', () => {
});

it('uses a precreated http server listening on IPC', (done) => {
const randomString = crypto.randomBytes(16).toString('hex');
const randomString = crypto.randomBytes(4).toString('hex');
const ipcPath =
process.platform === 'win32'
? `\\\\.\\pipe\\ws-pipe-${randomString}`
Expand Down
16 changes: 8 additions & 8 deletions test/websocket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ describe('WebSocket', () => {
it("emits an 'error' event if an error occurs (2/2)", function (done) {
if (!fs.openAsBlob) return this.skip();

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

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

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

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

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

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

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

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

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

const randomString1 = crypto.randomBytes(16).toString('hex');
const randomString2 = crypto.randomBytes(16).toString('hex');
const randomString1 = crypto.randomBytes(4).toString('hex');
const randomString2 = crypto.randomBytes(4).toString('hex');
let redirectingServerIpcPath;
let redirectedServerIpcPath;

Expand Down Expand Up @@ -2025,7 +2025,7 @@ describe('WebSocket', () => {
ws.close();
});

const randomString = crypto.randomBytes(16).toString('hex');
const randomString = crypto.randomBytes(4).toString('hex');
const ipcPath =
process.platform === 'win32'
? `\\\\.\\pipe\\ws-pipe-${randomString}`
Expand Down

0 comments on commit 021f7b8

Please sign in to comment.