|
| 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 {createPrivateKey} from 'node:crypto'; |
| 8 | +import * as fixtures from '../common/fixtures.mjs'; |
| 9 | + |
| 10 | +const {readKey} = fixtures; |
| 11 | + |
| 12 | +if (!hasQuic) { |
| 13 | + skip('QUIC is not enabled'); |
| 14 | +} |
| 15 | + |
| 16 | +const {listen, connect} = await import('../common/quic.mjs'); |
| 17 | + |
| 18 | +const serverKey = createPrivateKey(readKey('agent1-key.pem')); |
| 19 | +const serverCert = readKey('agent1-cert.pem'); |
| 20 | + |
| 21 | +const done = Promise.withResolvers(); |
| 22 | + |
| 23 | +const serverEndpoint = await listen(mustCall(async (session) => { |
| 24 | + await session.opened; |
| 25 | + done.resolve(); |
| 26 | +}), { |
| 27 | + sni: { '*': { keys: [serverKey], certs: [serverCert] } }, |
| 28 | + alpn: ['repro'], |
| 29 | +}); |
| 30 | + |
| 31 | +const clientSession = await connect(serverEndpoint.address, { |
| 32 | + servername: 'localhost', |
| 33 | + alpn: 'repro', |
| 34 | + ca: serverCert, |
| 35 | +}); |
| 36 | + |
| 37 | +await clientSession.opened; |
| 38 | + |
| 39 | +await clientSession.createUnidirectionalStream({ |
| 40 | + body: 'something something darkside', |
| 41 | +}); |
| 42 | + |
| 43 | +await done.promise; |
| 44 | + |
| 45 | +await clientSession.close(); |
| 46 | + |
| 47 | +await serverEndpoint.close(); |
0 commit comments