summaryrefslogtreecommitdiff
path: root/test/parallel/test-crypto-hash-stream-pipeline.js
blob: 4e4cdcfd7fccd54eafb12892017fe81de4bf9c1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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();