Skip to content

Commit 65c5d0e

Browse files
trivikrMylesBorins
authored andcommitted
test: consolidate http2 tests in one file
PR-URL: #15624 Refs: #14985 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 6ad5b90 commit 65c5d0e

9 files changed

+47
-310
lines changed

test/parallel/test-http2-server-destroy-before-additional.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

test/parallel/test-http2-server-destroy-before-priority.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

test/parallel/test-http2-server-destroy-before-push.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

test/parallel/test-http2-server-destroy-before-respond.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

test/parallel/test-http2-server-destroy-before-rst.js

Lines changed: 0 additions & 41 deletions
This file was deleted.

test/parallel/test-http2-server-destroy-before-shutdown.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

test/parallel/test-http2-server-destroy-before-state.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

test/parallel/test-http2-server-destroy-before-write.js

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
const assert = require('assert');
7+
const h2 = require('http2');
8+
9+
const server = h2.createServer();
10+
11+
server.on(
12+
'stream',
13+
common.mustCall((stream) => {
14+
const errorObj = {
15+
type: Error,
16+
code: 'ERR_HTTP2_INVALID_STREAM',
17+
message: 'The stream has been destroyed'
18+
};
19+
stream.session.destroy();
20+
21+
// Test that stream.state getter returns an empty object
22+
// when the stream session has been destroyed
23+
assert.deepStrictEqual(Object.create(null), stream.state);
24+
25+
// Test that ERR_HTTP2_INVALID_STREAM is thrown while calling
26+
// stream operations after the stream session has been destroyed
27+
common.expectsError(() => stream.additionalHeaders(), errorObj);
28+
common.expectsError(() => stream.priority(), errorObj);
29+
common.expectsError(
30+
() => stream.pushStream({}, common.mustNotCall()),
31+
errorObj
32+
);
33+
common.expectsError(() => stream.respond(), errorObj);
34+
common.expectsError(() => stream.rstStream(), errorObj);
35+
common.expectsError(() => stream.write('data'), errorObj);
36+
})
37+
);
38+
39+
server.listen(
40+
0,
41+
common.mustCall(() => {
42+
const client = h2.connect(`http://localhost:${server.address().port}`);
43+
const req = client.request();
44+
req.resume();
45+
req.on('end', common.mustCall(() => server.close()));
46+
})
47+
);

0 commit comments

Comments
 (0)