File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1+ import QUICConnectionId from '@/QUICConnectionId' ;
2+ import { quiche } from '@/native' ;
3+ import * as testsUtils from './utils' ;
4+
5+ describe ( QUICConnectionId . name , ( ) => {
6+ test ( 'connection ID is a Uint8Array' , async ( ) => {
7+ const cidBuffer = new ArrayBuffer ( quiche . MAX_CONN_ID_LEN ) ;
8+ await testsUtils . randomBytes ( cidBuffer ) ;
9+ const cid = new QUICConnectionId ( cidBuffer ) ;
10+ expect ( cid ) . toBeInstanceOf ( Uint8Array ) ;
11+ } ) ;
12+ test ( 'connection ID encode to hex string and decode from hex string' , async ( ) => {
13+ const cidBuffer = new ArrayBuffer ( quiche . MAX_CONN_ID_LEN ) ;
14+ await testsUtils . randomBytes ( cidBuffer ) ;
15+ const cid = new QUICConnectionId ( cidBuffer ) ;
16+ const cidString = cid . toString ( ) ;
17+ const cid_ = QUICConnectionId . fromString ( cidString ) ;
18+ expect ( cid ) . toEqual ( cid_ ) ;
19+ } ) ;
20+ test ( 'connection ID to buffer and from buffer is zero-copy' , async ( ) => {
21+ const cidBuffer = new ArrayBuffer ( quiche . MAX_CONN_ID_LEN ) ;
22+ await testsUtils . randomBytes ( cidBuffer ) ;
23+ const cid = new QUICConnectionId ( cidBuffer ) ;
24+ expect ( cid . toBuffer ( ) . buffer ) . toBe ( cidBuffer ) ;
25+ const cid_ = QUICConnectionId . fromBuffer ( cid . toBuffer ( ) ) ;
26+ expect ( cid_ . buffer ) . toBe ( cidBuffer ) ;
27+ } ) ;
28+ } ) ;
You can’t perform that action at this time.
0 commit comments