diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-http2-many-writes-and-destroy.js | 30 | ||||
-rw-r--r-- | test/parallel/test-http2-pipe.js | 1 | ||||
-rw-r--r-- | test/parallel/test-http2-server-close-callback.js | 24 | ||||
-rw-r--r-- | test/parallel/test-http2-server-stream-session-destroy.js | 12 | ||||
-rw-r--r-- | test/parallel/test-http2-session-unref.js | 14 | ||||
-rw-r--r-- | test/sequential/test-http2-max-session-memory.js | 4 |
6 files changed, 78 insertions, 7 deletions
diff --git a/test/parallel/test-http2-many-writes-and-destroy.js b/test/parallel/test-http2-many-writes-and-destroy.js new file mode 100644 index 0000000000..78db76e001 --- /dev/null +++ b/test/parallel/test-http2-many-writes-and-destroy.js @@ -0,0 +1,30 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); +const http2 = require('http2'); + +{ + const server = http2.createServer((req, res) => { + req.pipe(res); + }); + + server.listen(0, () => { + const url = `http://localhost:${server.address().port}`; + const client = http2.connect(url); + const req = client.request({ ':method': 'POST' }); + + for (let i = 0; i < 4000; i++) { + req.write(Buffer.alloc(6)); + } + + req.on('close', common.mustCall(() => { + console.log('(req onclose)'); + server.close(); + client.close(); + })); + + req.once('data', common.mustCall(() => req.destroy())); + }); +} diff --git a/test/parallel/test-http2-pipe.js b/test/parallel/test-http2-pipe.js index 2a759f9848..d7dd99df91 100644 --- a/test/parallel/test-http2-pipe.js +++ b/test/parallel/test-http2-pipe.js @@ -33,6 +33,7 @@ server.listen(0, common.mustCall(() => { const client = http2.connect(`http://localhost:${server.address().port}`); const req = client.request({ ':method': 'POST' }); + req.on('response', common.mustCall()); req.resume(); diff --git a/test/parallel/test-http2-server-close-callback.js b/test/parallel/test-http2-server-close-callback.js new file mode 100644 index 0000000000..66887aa62b --- /dev/null +++ b/test/parallel/test-http2-server-close-callback.js @@ -0,0 +1,24 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); + +const http2 = require('http2'); + +const server = http2.createServer(); + +server.listen(0, common.mustCall(() => { + const client = http2.connect(`http://localhost:${server.address().port}`); + client.on('error', (err) => { + if (err.code !== 'ECONNRESET') + throw err; + }); +})); + +server.on('session', common.mustCall((s) => { + setImmediate(() => { + server.close(common.mustCall()); + s.destroy(); + }); +})); diff --git a/test/parallel/test-http2-server-stream-session-destroy.js b/test/parallel/test-http2-server-stream-session-destroy.js index 989c72ec95..ef4f42fe39 100644 --- a/test/parallel/test-http2-server-stream-session-destroy.js +++ b/test/parallel/test-http2-server-stream-session-destroy.js @@ -44,10 +44,16 @@ server.on('stream', common.mustCall((stream) => { server.listen(0, common.mustCall(() => { const client = h2.connect(`http://localhost:${server.address().port}`); - client.on('error', () => {}); + client.on('error', (err) => { + if (err.code !== 'ECONNRESET') + throw err; + }); const req = client.request(); req.resume(); req.on('end', common.mustCall()); - req.on('close', common.mustCall(() => server.close())); - req.on('error', () => {}); + req.on('close', common.mustCall(() => server.close(common.mustCall()))); + req.on('error', (err) => { + if (err.code !== 'ECONNRESET') + throw err; + }); })); diff --git a/test/parallel/test-http2-session-unref.js b/test/parallel/test-http2-session-unref.js index e63cd0d208..f946c2d337 100644 --- a/test/parallel/test-http2-session-unref.js +++ b/test/parallel/test-http2-session-unref.js @@ -34,8 +34,11 @@ server.listen(0, common.mustCall(() => { // unref destroyed client { const client = http2.connect(`http://localhost:${port}`); - client.destroy(); - client.unref(); + + client.on('connect', common.mustCall(() => { + client.destroy(); + client.unref(); + })); } // unref destroyed client @@ -43,8 +46,11 @@ server.listen(0, common.mustCall(() => { const client = http2.connect(`http://localhost:${port}`, { createConnection: common.mustCall(() => clientSide) }); - client.destroy(); - client.unref(); + + client.on('connect', common.mustCall(() => { + client.destroy(); + client.unref(); + })); } })); server.emit('connection', serverSide); diff --git a/test/sequential/test-http2-max-session-memory.js b/test/sequential/test-http2-max-session-memory.js index d6d3bf935d..644a20a3c8 100644 --- a/test/sequential/test-http2-max-session-memory.js +++ b/test/sequential/test-http2-max-session-memory.js @@ -13,6 +13,10 @@ const largeBuffer = Buffer.alloc(1e6); const server = http2.createServer({ maxSessionMemory: 1 }); server.on('stream', common.mustCall((stream) => { + stream.on('error', (err) => { + if (err.code !== 'ECONNRESET') + throw err; + }); stream.respond(); stream.end(largeBuffer); })); |