Skip to content

Commit 35e5ee2

Browse files
committed
quic: Fix new test and lint
1 parent 51f2af6 commit 35e5ee2

File tree

2 files changed

+46
-48
lines changed

2 files changed

+46
-48
lines changed

test/common/quic/test-helpers.mjs

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
// start demo data
2-
// taken from @fails-components/webtransport tests
3-
// by the original author
4-
function createBytesChunk(length) {
5-
const workArray = new Array(length / 2);
6-
for (let i = 0; i < length / 4; i++) {
7-
workArray[2 * i + 1] = length % 0xffff;
8-
workArray[2 * i] = i;
9-
}
10-
const helper = new Uint16Array(workArray);
11-
const toreturn = new Uint8Array(
12-
helper.buffer,
13-
helper.byteOffset,
14-
helper.byteLength
15-
);
16-
return toreturn;
17-
}
18-
19-
// The number in the comments, help you identify the chunk, as it is the length first two bytes
20-
// this is helpful, when debugging buffer passing
21-
export const KNOWN_BYTES_LONG = [
22-
createBytesChunk(60000), // 96, 234
23-
createBytesChunk(12), // 0, 12
24-
createBytesChunk(50000), // 195, 80
25-
createBytesChunk(1600).buffer, // 6, 64 we use buffer here to increae test coverage
26-
createBytesChunk(20000), // 78, 32
27-
createBytesChunk(30000), // 117, 48
28-
];
29-
30-
// end demo data
31-
32-
export function uint8concat(arrays) {
33-
const length = arrays.reduce((acc, curr) => acc + curr.length, 0);
34-
const result = new Uint8Array(length);
35-
let pos = 0;
36-
let array = 0;
37-
while (pos < length) {
38-
const curArr = arrays[array];
39-
const curLen = curArr.byteLength;
40-
const dest = new Uint8Array(result.buffer, result.byteOffset + pos, curLen);
41-
dest.set(curArr);
42-
array++;
43-
pos += curArr.byteLength;
44-
}
45-
}
1+
// start demo data
2+
// taken from @fails-components/webtransport tests
3+
// by the original author
4+
function createBytesChunk(length) {
5+
const workArray = new Array(length / 2);
6+
for (let i = 0; i < length / 4; i++) {
7+
workArray[2 * i + 1] = length % 0xffff;
8+
workArray[2 * i] = i;
9+
}
10+
const helper = new Uint16Array(workArray);
11+
const toreturn = new Uint8Array(
12+
helper.buffer,
13+
helper.byteOffset,
14+
helper.byteLength,
15+
);
16+
return toreturn;
17+
}
18+
19+
// The number in the comments, help you identify the chunk, as it is the length first two bytes
20+
// this is helpful, when debugging buffer passing
21+
export const KNOWN_BYTES_LONG = [
22+
createBytesChunk(60000), // 96, 234
23+
createBytesChunk(12), // 0, 12
24+
createBytesChunk(50000), // 195, 80
25+
createBytesChunk(1600).buffer, // 6, 64 we use buffer here to increae test coverage
26+
createBytesChunk(20000), // 78, 32
27+
createBytesChunk(30000), // 117, 48
28+
];
29+
30+
// end demo data
31+
32+
export function uint8concat(arrays) {
33+
const length = arrays.reduce((acc, curr) => acc + curr.length, 0);
34+
const result = new Uint8Array(length);
35+
let pos = 0;
36+
let array = 0;
37+
while (pos < length) {
38+
const curArr = arrays[array];
39+
const curLen = curArr.byteLength;
40+
const dest = new Uint8Array(result.buffer, result.byteOffset + pos, curLen);
41+
dest.set(curArr);
42+
array++;
43+
pos += curArr.byteLength;
44+
}
45+
}

test/parallel/test-quic-client-to-server-unidirectional.mjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const serverEndpoint = await listen(async (serverSession) => {
2626
strictEqual(stream.direction, 'uni', 'Expects an unidirectional stream');
2727
const reader = stream.readable.getReader();
2828
const readChunks = [];
29-
let readc = 0;
3029
while (true) {
3130
const { done, value } = await reader.read();
3231
// if (readc > 20) throw new Error("after read " + readc);
@@ -67,7 +66,6 @@ sendStream.closed.catch(() => {
6766
strictEqual(sendStream.direction, 'uni');
6867
const clientWritable = transformStream.writable;
6968
const writer = clientWritable.getWriter();
70-
let run = 0
7169
for (const chunk of KNOWN_BYTES_LONG) {
7270
await writer.ready;
7371
await writer.write(chunk);
@@ -79,4 +77,4 @@ clientSession.closed.catch((err) => {
7977
// ignore the error
8078
});
8179
clientSession.close();
82-
await serverFinished.promise;
80+
await serverFinished.promise;

0 commit comments

Comments
 (0)