@@ -11,35 +11,18 @@ const h2 = require('http2'); |
11 | 11 | const net = require('net'); |
12 | 12 | const { NghttpError } = require('internal/http2/util'); |
13 | 13 | const h2test = require('../common/http2'); |
14 | | -let client; |
15 | 14 |
|
16 | 15 | const server = h2.createServer(); |
17 | | -let gotFirstStreamId1; |
18 | 16 | server.on('stream', common.mustCall((stream) => { |
19 | 17 | stream.respond(); |
20 | 18 | stream.end('ok'); |
21 | 19 |
|
22 | | - // Http2Server should be fast enough to respond to and close |
23 | | - // the first streams with ID 1 and ID 3 without errors. |
24 | | - |
25 | | - // Test for errors in 'close' event to ensure no errors on some streams. |
26 | | - stream.on('error', () => {}); |
27 | | - stream.on('close', (err) => { |
28 | | - if (stream.id === 1) { |
29 | | - if (gotFirstStreamId1) { |
30 | | - // We expect our outgoing frames to fail on Stream ID 1 the second time |
31 | | - // because a stream with ID 1 was already closed before. |
32 | | - common.expectsError({ |
33 | | - constructor: NghttpError, |
34 | | - code: 'ERR_HTTP2_ERROR', |
35 | | - message: 'Stream was already closed or invalid' |
36 | | - }); |
37 | | - return; |
38 | | - } |
39 | | - gotFirstStreamId1 = true; |
40 | | - } |
41 | | - assert.strictEqual(err, undefined); |
42 | | - }); |
| 20 | + stream.on('error', common.expectsError({ |
| 21 | + code: 'ERR_HTTP2_ERROR', |
| 22 | + constructor: NghttpError, |
| 23 | + message: 'Stream was already closed or invalid' |
| 24 | + })); |
| 25 | + stream.on('close', common.mustCall()); |
43 | 26 |
|
44 | 27 | // Stream ID 5 should never reach the server |
45 | 28 | assert.notStrictEqual(stream.id, 5); |
@@ -62,7 +45,7 @@ const id3 = new h2test.HeadersFrame(3, h2test.kFakeRequestHeaders, 0, true); |
62 | 45 | const id5 = new h2test.HeadersFrame(5, h2test.kFakeRequestHeaders, 0, true); |
63 | 46 |
|
64 | 47 | server.listen(0, () => { |
65 | | - client = net.connect(server.address().port, () => { |
| 48 | + const client = net.connect(server.address().port, () => { |
66 | 49 | client.write(h2test.kClientMagic, () => { |
67 | 50 | client.write(settings.data, () => { |
68 | 51 | client.write(settingsAck.data); |
|