|
| 1 | +// Flags: --experimental-quic --no-warnings |
| 2 | +// Test: client-initiated unidirectional stream with no onstream |
| 3 | +// The client creates a uni stream with no onstream. |
| 4 | +// Verify that this causes no crash. |
| 5 | + |
| 6 | +import{hasQuic,skip,mustCall}from'../common/index.mjs'; |
| 7 | +import*asfixturesfrom'../common/fixtures.mjs'; |
| 8 | + |
| 9 | +const{ readKey }=fixtures; |
| 10 | + |
| 11 | +if(!hasQuic){ |
| 12 | +skip('QUIC is not enabled'); |
| 13 | +} |
| 14 | + |
| 15 | +const{ createPrivateKey }=awaitimport('node:crypto'); |
| 16 | +const{ listen, connect }=awaitimport('../common/quic.mjs'); |
| 17 | + |
| 18 | +constserverKey=createPrivateKey(readKey('agent1-key.pem')); |
| 19 | +constserverCert=readKey('agent1-cert.pem'); |
| 20 | + |
| 21 | +constdone=Promise.withResolvers(); |
| 22 | + |
| 23 | +constserverEndpoint=awaitlisten(mustCall(async(session)=>{ |
| 24 | +awaitsession.opened; |
| 25 | +done.resolve(); |
| 26 | +}),{ |
| 27 | +sni: {'*': {keys: [serverKey],certs: [serverCert]}}, |
| 28 | +alpn: ['repro'], |
| 29 | +}); |
| 30 | + |
| 31 | +constclientSession=awaitconnect(serverEndpoint.address,{ |
| 32 | +servername: 'localhost', |
| 33 | +alpn: 'repro', |
| 34 | +ca: serverCert, |
| 35 | +}); |
| 36 | + |
| 37 | +awaitclientSession.opened; |
| 38 | + |
| 39 | +awaitclientSession.createUnidirectionalStream({ |
| 40 | +body: 'something something darkside', |
| 41 | +}); |
| 42 | + |
| 43 | +awaitdone.promise; |
| 44 | + |
| 45 | +awaitclientSession.close(); |
| 46 | + |
| 47 | +awaitserverEndpoint.close(); |
0 commit comments