Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
test: cut the subscriber mode tests down to the cases the fix needs
  • Loading branch information
askalf committed Oct 5, 2026
commit 8f949b486bc90f469d819c3b5204d4476fb76a0c
32 changes: 0 additions & 32 deletions test/helpers/mock_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,35 +222,3 @@ export function pubSubReply(
}
return [type, channel, value];
}

// `pubSubReply` goes through the string-based writer, which cannot carry a
// channel name that is not valid utf8. This builds the same reply as raw bytes
// instead, for the binary-safe channel names, and returns a Buffer to write to
// the socket directly (RESP3 push frame or RESP2 array, as the protocol asks).
export function rawPubSubReply(
protocol: MockServerProtocol,
type: string,
channel: string | Buffer,
value: string | number = 1
): Buffer {
const channelBytes = Buffer.isBuffer(channel)
? channel
: Buffer.from(channel);
const parts = [
Buffer.from(`${protocol === 3 ? ">" : "*"}3\r\n`),
blobString(Buffer.from(type)),
blobString(channelBytes),
typeof value === "number"
? Buffer.from(`:${value}\r\n`)
: blobString(Buffer.from(value)),
];
return Buffer.concat(parts);
}

function blobString(payload: Buffer): Buffer {
return Buffer.concat([
Buffer.from(`$${payload.length}\r\n`),
payload,
Buffer.from("\r\n"),
]);
}
Loading
Loading