From 1c6fbd6ffe7eb10053be3cfb84dc4ae11b4d94c3 Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Wed, 20 Jan 2021 09:15:54 -0600 Subject: [PATCH] test: add test that verifies crypto stream pipeline This test fails prior to 990feafcb6 being cherry-picked due to stream.pipeline with a crypto.Hash not working properly. That bug also seems to have affected md5. PR-URL: https://github.com/nodejs/node/pull/37009 Reviewed-By: Richard Lau Reviewed-By: Shelley Vohr --- .../test-crypto-hash-stream-pipeline.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/parallel/test-crypto-hash-stream-pipeline.js diff --git a/test/parallel/test-crypto-hash-stream-pipeline.js b/test/parallel/test-crypto-hash-stream-pipeline.js new file mode 100644 index 00000000000000..4e4cdcfd7fccd5 --- /dev/null +++ b/test/parallel/test-crypto-hash-stream-pipeline.js @@ -0,0 +1,21 @@ +'use strict'; + +const common = require('../common'); + +if (!common.hasCrypto) + common.skip('missing crypto'); + +const assert = require('assert'); +const crypto = require('crypto'); +const stream = require('stream'); + +const hash = crypto.createHash('md5'); +const s = new stream.PassThrough(); +const expect = 'e8dc4081b13434b45189a720b77b6818'; + +s.write('abcdefgh'); +stream.pipeline(s, hash, common.mustCall(function(err) { + assert.ifError(err); + assert.strictEqual(hash.digest('hex'), expect); +})); +s.end();