From f9499edbca215f3a90dd45e3dab69a10c7183da3 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Wed, 17 Nov 2021 20:09:37 +0100 Subject: [PATCH 1/3] test: use descriptive name for destination file `http2-url-tests.js` is misleading. Use the same name of the source file instead. --- test/parallel/test-http2-pipe-named-pipe.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-http2-pipe-named-pipe.js b/test/parallel/test-http2-pipe-named-pipe.js index 7882f79657f701..5d4f2caadb5e53 100644 --- a/test/parallel/test-http2-pipe-named-pipe.js +++ b/test/parallel/test-http2-pipe-named-pipe.js @@ -15,7 +15,7 @@ const path = require('path'); const tmpdir = require('../common/tmpdir'); tmpdir.refresh(); const loc = fixtures.path('person-large.jpg'); -const fn = path.join(tmpdir.path, 'http2-url-tests.js'); +const fn = path.join(tmpdir.path, 'person-large.jpg'); const server = http2.createServer(); From f704d99c4db88d8e789e9417984a23be335ba644 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Wed, 17 Nov 2021 20:18:10 +0100 Subject: [PATCH 2/3] test: deflake http2-pipe-named-pipe Wait for all data to be read before sending the response and closing the client. Fixes: https://github.com/nodejs/node/issues/40277 --- test/parallel/test-http2-pipe-named-pipe.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-http2-pipe-named-pipe.js b/test/parallel/test-http2-pipe-named-pipe.js index 5d4f2caadb5e53..226ae80932a65c 100644 --- a/test/parallel/test-http2-pipe-named-pipe.js +++ b/test/parallel/test-http2-pipe-named-pipe.js @@ -22,12 +22,15 @@ const server = http2.createServer(); server.on('stream', common.mustCall((stream) => { const dest = stream.pipe(fs.createWriteStream(fn)); - dest.on('finish', () => { + stream.on('end', common.mustCall(() => { + stream.respond(); + stream.end(); + })); + + dest.on('finish', common.mustCall(() => { assert.strictEqual(fs.readFileSync(loc).length, fs.readFileSync(fn).length); - }); - stream.respond(); - stream.end(); + })); })); server.listen(common.PIPE, common.mustCall(() => { From 570123aa320d0d7ea4ae8990f03c7841abcc422a Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Wed, 17 Nov 2021 20:31:03 +0100 Subject: [PATCH 3/3] test: fix argument order in assertion The first argument is the actual value, the second argument is the expected value. --- test/parallel/test-http2-pipe-named-pipe.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-http2-pipe-named-pipe.js b/test/parallel/test-http2-pipe-named-pipe.js index 226ae80932a65c..0ef05da1935d8c 100644 --- a/test/parallel/test-http2-pipe-named-pipe.js +++ b/test/parallel/test-http2-pipe-named-pipe.js @@ -28,8 +28,8 @@ server.on('stream', common.mustCall((stream) => { })); dest.on('finish', common.mustCall(() => { - assert.strictEqual(fs.readFileSync(loc).length, - fs.readFileSync(fn).length); + assert.strictEqual(fs.readFileSync(fn).length, + fs.readFileSync(loc).length); })); }));