node/test/parallel/test-crypto-hash-stream-pipeline.js
Evan Lucas 1c6fbd6ffe
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>
2021-02-08 15:38:12 +00:00

22 lines
505 B
JavaScript

'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();