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 <rlau@redhat.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
This commit is contained in:
Evan Lucas authored and Richard Lau committed 2021-02-08 15:38:12 +00:00
1 parent 953a85035d
commit 1c6fbd6ffe
1 file changed
+21
@@ -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();