@@ -1654,7 +1654,7 @@ describe(QUICClient.name, () => {
16541654 await server . stop ( ) ;
16551655 } ) ;
16561656 } ) ;
1657- test ( 'Connections are established and secured quickly' , async ( ) => {
1657+ test ( 'connections are established and secured quickly' , async ( ) => {
16581658 const tlsConfigServer = await testsUtils . generateTLSConfig ( defaultType ) ;
16591659
16601660 const connectionEventProm = promise < events . EventQUICServerConnection > ( ) ;
@@ -1808,6 +1808,73 @@ describe(QUICClient.name, () => {
18081808 errors . ErrorQUICConnectionIdleTimeout ,
18091809 ) ;
18101810
1811+ await client . destroy ( { force : true } ) ;
1812+ await server . stop ( { force : true } ) ;
1813+ } ) ;
1814+ test ( 'connections share the same id information' , async ( ) => {
1815+ const tlsConfigServer = await testsUtils . generateTLSConfig ( defaultType ) ;
1816+
1817+ const { p : serverConnectionP , resolveP : serverConnectionResolveP } =
1818+ promise < QUICConnection > ( ) ;
1819+ const server = new QUICServer ( {
1820+ crypto : {
1821+ key,
1822+ ops : serverCryptoOps ,
1823+ } ,
1824+ logger : logger . getChild ( QUICServer . name ) ,
1825+ config : {
1826+ key : tlsConfigServer . leafKeyPairPEM . privateKey ,
1827+ cert : tlsConfigServer . leafCertPEM ,
1828+ verifyPeer : false ,
1829+ } ,
1830+ } ) ;
1831+ socketCleanMethods . extractSocket ( server ) ;
1832+ server . addEventListener (
1833+ events . EventQUICServerConnection . name ,
1834+ ( evt : events . EventQUICServerConnection ) => {
1835+ serverConnectionResolveP ( evt . detail ) ;
1836+ } ,
1837+ ) ;
1838+ await server . start ( {
1839+ host : localhost ,
1840+ } ) ;
1841+ // If the server is slow to respond then this will time out.
1842+ // Then main cause of this was the server not processing the initial packet
1843+ // that creates the `QUICConnection`, as a result, the whole creation waited
1844+ // an extra 1 second for the client to retry the initial packet.
1845+ const client = await QUICClient . createQUICClient (
1846+ {
1847+ host : localhost ,
1848+ port : server . port ,
1849+ localHost : localhost ,
1850+ crypto : {
1851+ ops : clientCryptoOps ,
1852+ } ,
1853+ logger : logger . getChild ( QUICClient . name ) ,
1854+ config : {
1855+ verifyPeer : false ,
1856+ } ,
1857+ } ,
1858+ { timer : 500 } ,
1859+ ) ;
1860+ socketCleanMethods . extractSocket ( client ) ;
1861+
1862+ const clientConn = client . connection ;
1863+ const serverConn = await serverConnectionP ;
1864+
1865+ expect (
1866+ Buffer . compare ( clientConn . connectionId , serverConn . connectionIdPeer ) ,
1867+ ) . toBe ( 0 ) ;
1868+ expect (
1869+ Buffer . compare ( clientConn . connectionIdPeer , serverConn . connectionId ) ,
1870+ ) . toBe ( 0 ) ;
1871+ expect (
1872+ Buffer . compare (
1873+ clientConn . connectionIdShared ,
1874+ serverConn . connectionIdShared ,
1875+ ) ,
1876+ ) . toBe ( 0 ) ;
1877+
18111878 await client . destroy ( { force : true } ) ;
18121879 await server . stop ( { force : true } ) ;
18131880 } ) ;
0 commit comments