mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Signed-off-by: haramjeong <04harams77@gmail.com> PR-URL: https://github.com/nodejs/node/pull/63261 Fixes: https://github.com/nodejs/node/issues/63258 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Filip Skokan <panva.ip@gmail.com>
33 lines
738 B
JavaScript
33 lines
738 B
JavaScript
'use strict';
|
|
|
|
// Flags: --expose-internals
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto) common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const crypto = require('crypto');
|
|
const { kHandle } = require('internal/crypto/util');
|
|
|
|
/**
|
|
* This test verifies that the Hash stream properly surfaces an error
|
|
* when the underlying native update fails.
|
|
*/
|
|
|
|
const h = crypto.createHash('sha256');
|
|
|
|
// Simulate native update failure by replacing the internal handle
|
|
const fakeHandle = {
|
|
update: () => false,
|
|
digest: () => Buffer.from('')
|
|
};
|
|
|
|
h[kHandle] = fakeHandle;
|
|
|
|
h.on('error', common.mustCall((err) => {
|
|
assert.strictEqual(err.code, 'ERR_CRYPTO_HASH_UPDATE_FAILED');
|
|
}));
|
|
|
|
h.write('test data');
|
|
h.end();
|