mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 09:08:46 +00:00

When configuring --without-ssl test-crypto-lazy-transform-writable.js fails with the following error: ``` Path: parallel/test-crypto-lazy-transform-writable internal/util.js:83 throw new Error('Node.js is not compiled with openssl crypto support'); ^ Error: Node.js is not compiled with openssl crypto support at Object.exports.assertCrypto (internal/util.js:83:11) at crypto.js:28:14 at NativeModule.compile (bootstrap_node.js:557:7) at Function.NativeModule.require (bootstrap_node.js:500:18) at Function.Module._load (module.js:446:25) at Module.require (module.js:526:17) at require (internal/module.js:19:18) at Object.<anonymous> (/Users/danielbevenius/work/nodejs/node/test/parallel/test-crypto-lazy-transform-writable.js:5:16) at Module._compile (module.js:607:30) at Object.Module._extensions..js (module.js:618:10) Command: out/Release/node /Users/danielbevenius/work/nodejs/node/test/parallel/test-crypto-lazy-transform-writable.js [01:29|% 100|+ 1461|- 1]: Done make: *** [test] Error 1 ``` This commit add a hasCrypto check like other crypto tests do. PR-URL: https://github.com/nodejs/node/pull/12424 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
39 lines
889 B
JavaScript
39 lines
889 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto) {
|
|
common.skip('missing crypto');
|
|
return;
|
|
}
|
|
const assert = require('assert');
|
|
const crypto = require('crypto');
|
|
const Stream = require('stream');
|
|
const util = require('util');
|
|
|
|
const hasher1 = crypto.createHash('sha256');
|
|
const hasher2 = crypto.createHash('sha256');
|
|
|
|
// Calculate the expected result.
|
|
hasher1.write(Buffer.from('hello world'));
|
|
hasher1.end();
|
|
|
|
const expected = hasher1.read().toString('hex');
|
|
|
|
function OldStream() {
|
|
Stream.call(this);
|
|
|
|
this.readable = true;
|
|
}
|
|
util.inherits(OldStream, Stream);
|
|
|
|
const stream = new OldStream();
|
|
|
|
stream.pipe(hasher2).on('finish', common.mustCall(function() {
|
|
const hash = hasher2.read().toString('hex');
|
|
assert.strictEqual(expected, hash);
|
|
}));
|
|
|
|
stream.emit('data', Buffer.from('hello'));
|
|
stream.emit('data', Buffer.from(' world'));
|
|
stream.emit('end');
|