quic: multiple updates to quic impl · nodejs/node@43c25e2

@@ -10,14 +10,18 @@ const {

10101111

describe('quic internal endpoint stats and state', { skip: !hasQuic }, () => {

1212

const {

13-

Endpoint,

13+

QuicEndpoint,

1414

QuicStreamState,

1515

QuicStreamStats,

16-

SessionState,

17-

SessionStats,

18-

kFinishClose,

16+

QuicSessionState,

17+

QuicSessionStats,

1918

} = require('internal/quic/quic');

201920+

const {

21+

kFinishClose,

22+

kPrivateConstructor,

23+

} = require('internal/quic/symbols');

24+2125

const {

2226

inspect,

2327

} = require('util');

@@ -29,7 +33,7 @@ describe('quic internal endpoint stats and state', { skip: !hasQuic }, () => {

2933

} = require('node:assert');

30343135

it('endpoint state', () => {

32-

const endpoint = new Endpoint({

36+

const endpoint = new QuicEndpoint({

3337

onsession() {},

3438

session: {},

3539

stream: {},

@@ -62,7 +66,7 @@ describe('quic internal endpoint stats and state', { skip: !hasQuic }, () => {

6266

});

63676468

it('state is not readable after close', () => {

65-

const endpoint = new Endpoint({

69+

const endpoint = new QuicEndpoint({

6670

onsession() {},

6771

session: {},

6872

stream: {},

@@ -74,24 +78,25 @@ describe('quic internal endpoint stats and state', { skip: !hasQuic }, () => {

7478

});

75797680

it('state constructor argument is ArrayBuffer', () => {

77-

const endpoint = new Endpoint({

81+

const endpoint = new QuicEndpoint({

7882

onsession() {},

7983

session: {},

8084

stream: {},

8185

}, {});

8286

const Cons = endpoint.state.constructor;

83-

throws(() => new Cons(1), {

87+

throws(() => new Cons(kPrivateConstructor, 1), {

8488

code: 'ERR_INVALID_ARG_TYPE'

8589

});

8690

});

87918892

it('endpoint stats', () => {

89-

const endpoint = new Endpoint({

93+

const endpoint = new QuicEndpoint({

9094

onsession() {},

9195

session: {},

9296

stream: {},

9397

});

949899+

strictEqual(typeof endpoint.stats.isConnected, 'boolean');

95100

strictEqual(typeof endpoint.stats.createdAt, 'bigint');

96101

strictEqual(typeof endpoint.stats.destroyedAt, 'bigint');

97102

strictEqual(typeof endpoint.stats.bytesReceived, 'bigint');

@@ -107,6 +112,7 @@ describe('quic internal endpoint stats and state', { skip: !hasQuic }, () => {

107112

strictEqual(typeof endpoint.stats.immediateCloseCount, 'bigint');

108113109114

deepStrictEqual(Object.keys(endpoint.stats.toJSON()), [

115+

'connected',

110116

'createdAt',

111117

'destroyedAt',

112118

'bytesReceived',

@@ -128,25 +134,26 @@ describe('quic internal endpoint stats and state', { skip: !hasQuic }, () => {

128134

});

129135130136

it('stats are still readble after close', () => {

131-

const endpoint = new Endpoint({

137+

const endpoint = new QuicEndpoint({

132138

onsession() {},

133139

session: {},

134140

stream: {},

135141

}, {});

136142

strictEqual(typeof endpoint.stats.toJSON(), 'object');

137143

endpoint.stats[kFinishClose]();

144+

strictEqual(endpoint.stats.isConnected, false);

138145

strictEqual(typeof endpoint.stats.destroyedAt, 'bigint');

139146

strictEqual(typeof endpoint.stats.toJSON(), 'object');

140147

});

141148142149

it('stats constructor argument is ArrayBuffer', () => {

143-

const endpoint = new Endpoint({

150+

const endpoint = new QuicEndpoint({

144151

onsession() {},

145152

session: {},

146153

stream: {},

147154

}, {});

148155

const Cons = endpoint.stats.constructor;

149-

throws(() => new Cons(1), {

156+

throws(() => new Cons(kPrivateConstructor, 1), {

150157

code: 'ERR_INVALID_ARG_TYPE',

151158

});

152159

});

@@ -156,8 +163,8 @@ describe('quic internal endpoint stats and state', { skip: !hasQuic }, () => {

156163

// temporarily while the rest of the functionality is being

157164

// implemented.

158165

it('stream and session states', () => {

159-

const streamState = new QuicStreamState(new ArrayBuffer(1024));

160-

const sessionState = new SessionState(new ArrayBuffer(1024));

166+

const streamState = new QuicStreamState(kPrivateConstructor, new ArrayBuffer(1024));

167+

const sessionState = new QuicSessionState(kPrivateConstructor, new ArrayBuffer(1024));

161168162169

strictEqual(streamState.finSent, false);

163170

strictEqual(streamState.finReceived, false);

@@ -195,8 +202,8 @@ describe('quic internal endpoint stats and state', { skip: !hasQuic }, () => {

195202

});

196203197204

it('stream and session stats', () => {

198-

const streamStats = new QuicStreamStats(new ArrayBuffer(1024));

199-

const sessionStats = new SessionStats(new ArrayBuffer(1024));

205+

const streamStats = new QuicStreamStats(kPrivateConstructor, new ArrayBuffer(1024));

206+

const sessionStats = new QuicSessionStats(kPrivateConstructor, new ArrayBuffer(1024));

200207

strictEqual(streamStats.createdAt, undefined);

201208

strictEqual(streamStats.receivedAt, undefined);

202209

strictEqual(streamStats.ackedAt, undefined);