test: http2 client operations after destroy

PR-URL: https://github.com/nodejs/node/pull/18845
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Trivikram 2018-02-17 18:29:22 -08:00 committed by James M Snell
parent e83adf87f5
commit 808c05858a

View File

@ -59,7 +59,6 @@ const Countdown = require('../common/countdown');
assert(socket.destroyed);
}));
const req = client.request();
req.on('error', common.expectsError({
code: 'ERR_HTTP2_STREAM_CANCEL',
@ -77,15 +76,21 @@ const Countdown = require('../common/countdown');
message: 'The session has been destroyed'
};
common.expectsError(() => client.request(), sessionError);
common.expectsError(() => client.setNextStreamID(), sessionError);
common.expectsError(() => client.ping(), sessionError);
common.expectsError(() => client.settings({}), sessionError);
common.expectsError(() => client.goaway(), sessionError);
common.expectsError(() => client.request(), sessionError);
client.close(); // should be a non-op at this point
// Wait for setImmediate call from destroy() to complete
// so that state.destroyed is set to true
setImmediate(() => {
common.expectsError(() => client.request(), sessionError);
common.expectsError(() => client.setNextStreamID(), sessionError);
common.expectsError(() => client.ping(), sessionError);
common.expectsError(() => client.settings({}), sessionError);
common.expectsError(() => client.goaway(), sessionError);
common.expectsError(() => client.request(), sessionError);
client.close(); // should be a non-op at this point
});