summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Lucas <evanlucas@me.com>2021-01-20 09:15:54 -0600
committerRichard Lau <rlau@redhat.com>2021-02-08 15:38:12 +0000
commit1c6fbd6ffe7eb10053be3cfb84dc4ae11b4d94c3 (patch)
tree094255a9846d72b9e001066af9de56c2699690b2
parent953a85035df05f3cb7763f801465a024ee0a5f1e (diff)
downloadnode-new-1c6fbd6ffe7eb10053be3cfb84dc4ae11b4d94c3.tar.gz
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>
-rw-r--r--test/parallel/test-crypto-hash-stream-pipeline.js21
1 files changed, 21 insertions, 0 deletions
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 0000000000..4e4cdcfd7f
--- /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();