Skip to content

Commit

Permalink
test: add test that verifies crypto stream pipeline
Browse files Browse the repository at this point in the history
This test fails prior to 990feaf being cherry-picked
due to stream.pipeline with a crypto.Hash not working properly.

That bug also seems to have affected md5.

PR-URL: #37009
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Shelley Vohr <codebytere@gmail.com>
  • Loading branch information
evanlucas authored and richardlau committed Feb 5, 2021
1 parent c16c314 commit f55ce7c
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/parallel/test-crypto-hash-stream-pipeline.js
Original file line number Diff line number Diff line change
@@ -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();

0 comments on commit f55ce7c

Please sign in to comment.