Skip to content

Commit

Permalink
test: Http2Stream server stream session destroy tests in one file
Browse files Browse the repository at this point in the history
Refs: #14985
  • Loading branch information
trivikr committed Sep 30, 2017
1 parent 2f2f1cf commit 3ffd096
Showing 8 changed files with 47 additions and 272 deletions.
39 changes: 0 additions & 39 deletions test/parallel/test-http2-server-destroy-before-additional.js

This file was deleted.

40 changes: 0 additions & 40 deletions test/parallel/test-http2-server-destroy-before-priority.js

This file was deleted.

39 changes: 0 additions & 39 deletions test/parallel/test-http2-server-destroy-before-push.js

This file was deleted.

39 changes: 0 additions & 39 deletions test/parallel/test-http2-server-destroy-before-respond.js

This file was deleted.

40 changes: 0 additions & 40 deletions test/parallel/test-http2-server-destroy-before-rst.js

This file was deleted.

36 changes: 0 additions & 36 deletions test/parallel/test-http2-server-destroy-before-state.js

This file was deleted.

39 changes: 0 additions & 39 deletions test/parallel/test-http2-server-destroy-before-write.js

This file was deleted.

47 changes: 47 additions & 0 deletions test/parallel/test-http2-server-stream-session-destroy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict';

const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const h2 = require('http2');

const server = h2.createServer();

server.on(
'stream',
common.mustCall((stream) => {
const errorObj = {
type: Error,
code: 'ERR_HTTP2_INVALID_STREAM',
message: 'The stream has been destroyed'
};
stream.session.destroy();

// Test that stream.state getter returns an empty object
// when the stream session has been destroyed
assert.deepStrictEqual(Object.create(null), stream.state);

// Test that ERR_HTTP2_INVALID_STREAM is thrown while calling
// stream operations after the stream session has been destroyed
common.expectsError(() => stream.additionalHeaders(), errorObj);
common.expectsError(() => stream.priority(), errorObj);
common.expectsError(
() => stream.pushStream({}, common.mustNotCall()),
errorObj
);
common.expectsError(() => stream.respond(), errorObj);
common.expectsError(() => stream.rstStream(), errorObj);
common.expectsError(() => stream.write('data'), errorObj);
})
);

server.listen(
0,
common.mustCall(() => {
const client = h2.connect(`http://localhost:${server.address().port}`);
const req = client.request();
req.resume();
req.on('end', common.mustCall(() => server.close()));
})
);

0 comments on commit 3ffd096

Please sign in to comment.