Skip to content

Commit f5f6a40

Browse files
committed
quic: Adhere to new js linting
1 parent 033558d commit f5f6a40

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

test/parallel/test-quic-client-to-server-bidirectional-echo.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Flags: --experimental-quic --no-warnings
22

33
import { hasQuic, skip, mustCall } from '../common/index.mjs';
4-
import { ok, strictEqual } from 'node:assert';
4+
import assert from 'node:assert';
55
import { readKey } from '../common/fixtures.mjs';
66
import { KNOWN_BYTES_LONG, uint8concat, equalUint8Arrays } from '../common/quic/test-helpers.mjs';
77
import { TransformStream } from 'node:stream/web';
@@ -19,9 +19,9 @@ const certs = readKey('agent1-cert.pem');
1919

2020
const finished = Promise.withResolvers();
2121

22-
const serverEndpoint = await listen(async (serverSession) => {
22+
const serverEndpoint = await listen(mustCall(async (serverSession) => {
2323
serverSession.onstream = mustCall(async (stream) => {
24-
strictEqual(stream.direction, 'bidi', 'Expects an bidirectional stream');
24+
assert.strictEqual(stream.direction, 'bidi');
2525
stream.closed.catch(() => {
2626
// ignore
2727
});
@@ -36,10 +36,10 @@ const serverEndpoint = await listen(async (serverSession) => {
3636
// ignore the error
3737
});
3838
serverSession.close();
39-
}, { keys, certs });
39+
}), { keys, certs });
4040

4141
// The server must have an address to connect to after listen resolves.
42-
ok(serverEndpoint.address !== undefined);
42+
assert.ok(serverEndpoint.address !== undefined);
4343

4444
const clientSession = await connect(serverEndpoint.address);
4545
await clientSession.opened;
@@ -50,7 +50,7 @@ const sendStream = await clientSession.createBidirectionalStream({ body: transfo
5050
sendStream.closed.catch(() => {
5151
// ignore
5252
});
53-
strictEqual(sendStream.direction, 'bidi');
53+
assert.strictEqual(sendStream.direction, 'bidi');
5454
const writeToStream = async () => {
5555
const clientWritable = transformStream.writable;
5656
const writer = clientWritable.getWriter();
@@ -61,20 +61,20 @@ const writeToStream = async () => {
6161
await writer.ready;
6262
await writer.close();
6363
};
64-
const readFromStream = async () => {
64+
const readFromStream = mustCall(async () => {
6565
const reader = sendStream.readable.getReader();
6666
const readChunks = [];
6767
while (true) {
6868
const { done, value } = await reader.read();
6969
if (value) {
70-
ok(value instanceof Uint8Array, 'Expects value to be a Uint8Array');
70+
assert.ok(value instanceof Uint8Array, 'Expects value to be a Uint8Array');
7171
readChunks.push(value);
7272
}
7373
if (done) break;
7474
}
7575
// Now compare what we got
7676
equalUint8Arrays(uint8concat(KNOWN_BYTES_LONG), uint8concat(readChunks));
77-
};
77+
});
7878

7979
await Promise.all([writeToStream(), readFromStream()]);
8080
clientSession.closed.catch((err) => {

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Flags: --experimental-quic --no-warnings
22

33
import { hasQuic, skip, mustCall } from '../common/index.mjs';
4-
import { ok, strictEqual } from 'node:assert';
4+
import assert from 'node:assert';
55
import { readKey } from '../common/fixtures.mjs';
66
import { KNOWN_BYTES_LONG, uint8concat, equalUint8Arrays } from '../common/quic/test-helpers.mjs';
77
import { TransformStream } from 'node:stream/web';
@@ -20,16 +20,16 @@ const certs = readKey('agent1-cert.pem');
2020
// The opened promise should resolve when the client finished reading
2121
const serverFinished = Promise.withResolvers();
2222

23-
const serverEndpoint = await listen(async (serverSession) => {
23+
const serverEndpoint = await listen(mustCall(async (serverSession) => {
2424
serverSession.onstream = mustCall(async (stream) => {
25-
strictEqual(stream.direction, 'uni', 'Expects an unidirectional stream');
25+
assert.strictEqual(stream.direction, 'uni');
2626
const reader = stream.readable.getReader();
2727
const readChunks = [];
2828
while (true) {
2929
const { done, value } = await reader.read();
3030
// if (readc > 20) throw new Error("after read " + readc);
3131
if (value) {
32-
ok(value instanceof Uint8Array, 'Expects value to be a Uint8Array');
32+
assert.ok(value instanceof Uint8Array, 'Expects value to be a Uint8Array');
3333
readChunks.push(value);
3434
}
3535
if (done) break;
@@ -47,10 +47,10 @@ const serverEndpoint = await listen(async (serverSession) => {
4747
// ignore the error
4848
});
4949
serverSession.close();
50-
}, { keys, certs });
50+
}), { keys, certs });
5151

5252
// The server must have an address to connect to after listen resolves.
53-
ok(serverEndpoint.address !== undefined);
53+
assert.ok(serverEndpoint.address !== undefined);
5454

5555
const clientSession = await connect(serverEndpoint.address);
5656
await clientSession.opened;
@@ -61,7 +61,7 @@ const sendStream = await clientSession.createUnidirectionalStream({ body: transf
6161
sendStream.closed.catch(() => {
6262
// ignore
6363
});
64-
strictEqual(sendStream.direction, 'uni');
64+
assert.strictEqual(sendStream.direction, 'uni');
6565
const clientWritable = transformStream.writable;
6666
const writer = clientWritable.getWriter();
6767
for (const chunk of KNOWN_BYTES_LONG) {

test/parallel/test-quic-server-to-client-bidirectional-echo.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Flags: --experimental-quic --no-warnings
22

33
import { hasQuic, skip, mustCall } from '../common/index.mjs';
4-
import { ok, strictEqual } from 'node:assert';
4+
import assert from 'node:assert';
55
import { readKey } from '../common/fixtures.mjs';
66
import { KNOWN_BYTES_LONG, uint8concat, equalUint8Arrays } from '../common/quic/test-helpers.mjs';
77
import { TransformStream } from 'node:stream/web';
@@ -19,7 +19,7 @@ const certs = readKey('agent1-cert.pem');
1919

2020
const finished = Promise.withResolvers();
2121

22-
const serverEndpoint = await listen(async (serverSession) => {
22+
const serverEndpoint = await listen(mustCall(async (serverSession) => {
2323
await serverSession.opened;
2424
const transformStream = new TransformStream();
2525
serverSession.closed.catch((err) => {
@@ -28,7 +28,7 @@ const serverEndpoint = await listen(async (serverSession) => {
2828
const sendStream = await serverSession.createBidirectionalStream({ body: transformStream.readable });
2929
// Now compare what we got
3030

31-
strictEqual(sendStream.direction, 'bidi');
31+
assert.strictEqual(sendStream.direction, 'bidi');
3232
sendStream.closed.catch(() => {
3333
// ignore
3434
});
@@ -42,33 +42,33 @@ const serverEndpoint = await listen(async (serverSession) => {
4242
await writer.ready;
4343
await writer.close();
4444
};
45-
const readFromStream = async () => {
45+
const readFromStream = mustCall(async () => {
4646
const reader = sendStream.readable.getReader();
4747
const readChunks = [];
4848
while (true) {
4949
const { done, value } = await reader.read();
5050
if (value) {
51-
ok(value instanceof Uint8Array, 'Expects value to be a Uint8Array');
51+
assert.ok(value instanceof Uint8Array, 'Expects value to be a Uint8Array');
5252
readChunks.push(value);
5353
}
5454
if (done) break;
5555
}
5656
equalUint8Arrays(uint8concat(KNOWN_BYTES_LONG), uint8concat(readChunks));
57-
};
57+
});
5858
await Promise.all([writeToStream(), readFromStream()]);
5959
serverSession.close();
6060
finished.resolve();
61-
}, { keys, certs });
61+
}), { keys, certs });
6262

6363
// The server must have an address to connect to after listen resolves.
64-
ok(serverEndpoint.address !== undefined);
64+
assert.ok(serverEndpoint.address !== undefined);
6565

6666
const clientSession = await connect(serverEndpoint.address);
6767
await clientSession.opened;
6868

6969

7070
clientSession.onstream = mustCall(async (stream) => {
71-
strictEqual(stream.direction, 'bidi', 'Expects an bidirectional stream');
71+
assert.strictEqual(stream.direction, 'bidi');
7272
stream.closed.catch(() => {
7373
// ignore
7474
});

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Flags: --experimental-quic --no-warnings
22

33
import { hasQuic, skip, mustCall } from '../common/index.mjs';
4-
import { ok, strictEqual } from 'node:assert';
4+
import assert from 'node:assert';
55
import { readKey } from '../common/fixtures.mjs';
66
import { KNOWN_BYTES_LONG, uint8concat, equalUint8Arrays } from '../common/quic/test-helpers.mjs';
77
import { TransformStream } from 'node:stream/web';
@@ -21,14 +21,14 @@ const certs = readKey('agent1-cert.pem');
2121
const clientFinished = Promise.withResolvers();
2222

2323

24-
const serverEndpoint = await listen(async (serverSession) => {
24+
const serverEndpoint = await listen(mustCall(async (serverSession) => {
2525
await serverSession.opened;
2626
const transformStream = new TransformStream();
2727
const sendStream = await serverSession.createUnidirectionalStream({ body: transformStream.readable });
2828
sendStream.closed.catch(() => {
2929
// ignore
3030
});
31-
strictEqual(sendStream.direction, 'uni');
31+
assert.strictEqual(sendStream.direction, 'uni');
3232
const serverWritable = transformStream.writable;
3333
const writer = serverWritable.getWriter();
3434
for (const chunk of KNOWN_BYTES_LONG) {
@@ -41,21 +41,21 @@ const serverEndpoint = await listen(async (serverSession) => {
4141
// ignore the error
4242
});
4343
serverSession.close();
44-
}, { keys, certs });
44+
}), { keys, certs });
4545

4646
// The server must have an address to connect to after listen resolves.
47-
ok(serverEndpoint.address !== undefined);
47+
assert.ok(serverEndpoint.address !== undefined);
4848

4949
const clientSession = await connect(serverEndpoint.address);
5050

5151
clientSession.onstream = mustCall(async (stream) => {
52-
strictEqual(stream.direction, 'uni', 'Expects an unidirectional stream');
52+
assert.strictEqual(stream.direction, 'uni');
5353
const reader = stream.readable.getReader();
5454
const readChunks = [];
5555
while (true) {
5656
const { done, value } = await reader.read();
5757
if (value) {
58-
ok(value instanceof Uint8Array, 'Expects value to be a Uint8Array');
58+
assert.ok(value instanceof Uint8Array, 'Expects value to be a Uint8Array');
5959
readChunks.push(value);
6060
}
6161
if (done) break;

0 commit comments

Comments
 (0)