99import assert from 'node:assert' ;
1010import * as fixtures from '../common/fixtures.mjs' ;
1111
12- const { strictEqual } = assert ;
13- const { readKey } = fixtures ;
14-
1512if ( ! hasCrypto ) {
1613 skip ( 'missing crypto' ) ;
1714}
@@ -22,9 +19,9 @@ if (!process.features.dtls) {
2219
2320const { listen, connect } = await import ( 'node:dtls' ) ;
2421
25- const cert = readKey ( 'agent1-cert.pem' ) . toString ( ) ;
26- const key = readKey ( 'agent1-key.pem' ) . toString ( ) ;
27- const ca = readKey ( 'ca1-cert.pem' ) . toString ( ) ;
22+ const cert = fixtures . readKey ( 'agent1-cert.pem' ) . toString ( ) ;
23+ const key = fixtures . readKey ( 'agent1-key.pem' ) . toString ( ) ;
24+ const ca = fixtures . readKey ( 'ca1-cert.pem' ) . toString ( ) ;
2825
2926const gotServerSession = Promise . withResolvers ( ) ;
3027
@@ -34,26 +31,26 @@ const server = listen(mustCall((session) => {
3431
3532// --- Endpoint state after listen(): bound and listening. ---
3633const es = server . state ;
37- strictEqual ( es . bound , true ) ;
38- strictEqual ( es . listening , true ) ;
39- strictEqual ( es . closing , false ) ;
40- strictEqual ( es . destroyed , false ) ;
41- strictEqual ( es . sessionCount , 0 ) ;
34+ assert . strictEqual ( es . bound , true ) ;
35+ assert . strictEqual ( es . listening , true ) ;
36+ assert . strictEqual ( es . closing , false ) ;
37+ assert . strictEqual ( es . destroyed , false ) ;
38+ assert . strictEqual ( es . sessionCount , 0 ) ;
4239
4340// The busy property is settable via the endpoint and reflected in the state view.
44- strictEqual ( server . busy , false ) ;
45- strictEqual ( es . busy , false ) ;
41+ assert . strictEqual ( server . busy , false ) ;
42+ assert . strictEqual ( es . busy , false ) ;
4643server . busy = true ;
47- strictEqual ( server . busy , true ) ;
48- strictEqual ( es . busy , true ) ;
44+ assert . strictEqual ( server . busy , true ) ;
45+ assert . strictEqual ( es . busy , true ) ;
4946server . busy = false ;
50- strictEqual ( es . busy , false ) ;
47+ assert . strictEqual ( es . busy , false ) ;
5148
5249// --- Endpoint onerror accessor. ---
53- strictEqual ( server . onerror , undefined ) ;
50+ assert . strictEqual ( server . onerror , undefined ) ;
5451const onEndpointError = mustNotCall ( ) ;
5552server . onerror = onEndpointError ;
56- strictEqual ( server . onerror , onEndpointError ) ;
53+ assert . strictEqual ( server . onerror , onEndpointError ) ;
5754
5855const client = connect ( '127.0.0.1' , server . address . port , {
5956 ca : [ ca ] ,
@@ -62,43 +59,43 @@ const client = connect('127.0.0.1', server.address.port, {
6259
6360// --- Session state during the handshake. ---
6461const cs = client . state ;
65- strictEqual ( cs . handshaking , true ) ;
66- strictEqual ( cs . open , false ) ;
67- strictEqual ( cs . closing , false ) ;
68- strictEqual ( cs . destroyed , false ) ;
69- strictEqual ( cs . hasMessageListener , false ) ;
62+ assert . strictEqual ( cs . handshaking , true ) ;
63+ assert . strictEqual ( cs . open , false ) ;
64+ assert . strictEqual ( cs . closing , false ) ;
65+ assert . strictEqual ( cs . destroyed , false ) ;
66+ assert . strictEqual ( cs . hasMessageListener , false ) ;
7067
7168// --- Session callback accessors: unset, then set. ---
72- strictEqual ( client . onmessage , undefined ) ;
73- strictEqual ( client . onerror , undefined ) ;
74- strictEqual ( client . onhandshake , undefined ) ;
75- strictEqual ( client . onkeylog , undefined ) ;
69+ assert . strictEqual ( client . onmessage , undefined ) ;
70+ assert . strictEqual ( client . onerror , undefined ) ;
71+ assert . strictEqual ( client . onhandshake , undefined ) ;
72+ assert . strictEqual ( client . onkeylog , undefined ) ;
7673// A connect() session owns its internal endpoint.
77- strictEqual ( client . ownsEndpoint , true ) ;
74+ assert . strictEqual ( client . ownsEndpoint , true ) ;
7875
7976client . onmessage = mustNotCall ( ) ;
80- strictEqual ( typeof client . onmessage , 'function' ) ;
77+ assert . strictEqual ( typeof client . onmessage , 'function' ) ;
8178// Attaching a message listener flips the shared flag.
82- strictEqual ( cs . hasMessageListener , true ) ;
79+ assert . strictEqual ( cs . hasMessageListener , true ) ;
8380
8481client . onerror = mustNotCall ( ) ;
85- strictEqual ( typeof client . onerror , 'function' ) ;
82+ assert . strictEqual ( typeof client . onerror , 'function' ) ;
8683
8784client . onhandshake = mustCall ( ) ;
88- strictEqual ( typeof client . onhandshake , 'function' ) ;
85+ assert . strictEqual ( typeof client . onhandshake , 'function' ) ;
8986
9087client . onkeylog = mustCallAtLeast ( ) ;
91- strictEqual ( typeof client . onkeylog , 'function' ) ;
88+ assert . strictEqual ( typeof client . onkeylog , 'function' ) ;
9289
9390await client . opened ;
9491
9592// --- Session state after the handshake completes. ---
96- strictEqual ( cs . handshaking , false ) ;
97- strictEqual ( cs . open , true ) ;
93+ assert . strictEqual ( cs . handshaking , false ) ;
94+ assert . strictEqual ( cs . open , true ) ;
9895
9996const serverSession = await gotServerSession . promise ;
10097await serverSession . opened ;
101- strictEqual ( es . sessionCount , 1 ) ;
98+ assert . strictEqual ( es . sessionCount , 1 ) ;
10299
103100await client . close ( ) ;
104101await server . close ( ) ;
0 commit comments