MCPcopy Index your code
hub / github.com/nodejs/node / transferAndGetPacketCount

Function transferAndGetPacketCount

test/parallel/test-quic-max-payload-size.mjs:23–50  ·  view source on GitHub ↗
(maxPayloadSize)

Source from the content-addressed store, hash-verified

21
22// Transfer with default maxPayloadSize (1200).
23async function transferAndGetPacketCount(maxPayloadSize) {
24 const serverDone = Promise.withResolvers();
25
26 const serverEndpoint = await listen(mustCall((serverSession) => {
27 serverSession.onstream = mustCall(async (stream) => {
28 const received = await bytes(stream);
29 strictEqual(received.byteLength, dataLength);
30 stream.writer.endSync();
31 await stream.closed;
32 serverSession.close();
33 serverDone.resolve();
34 });
35 }), maxPayloadSize ? { maxPayloadSize } : {});
36
37 const clientSession = await connect(serverEndpoint.address,
38 maxPayloadSize ? { maxPayloadSize } : {});
39 await clientSession.opened;
40
41 const stream = await clientSession.createBidirectionalStream();
42 stream.setBody(new Uint8Array(dataLength));
43 for await (const _ of stream) { /* drain */ } // eslint-disable-line no-unused-vars
44 await Promise.all([stream.closed, serverDone.promise]);
45
46 const pktSent = clientSession.stats.pktSent;
47 await clientSession.closed;
48 await serverEndpoint.close();
49 return pktSent;
50}
51
52const defaultPkts = await transferAndGetPacketCount();
53const smallPkts = await transferAndGetPacketCount(1200);

Callers 1

Calls 10

setBodyMethod · 0.80
allMethod · 0.80
listenFunction · 0.70
mustCallFunction · 0.70
connectFunction · 0.70
closeMethod · 0.65
bytesFunction · 0.50
endSyncMethod · 0.45
resolveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…