diff options
author | Calvin Metcalf <cmetcalf@appgeo.com> | 2016-04-04 15:35:29 -0400 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-04-18 16:00:41 -0700 |
commit | 1d9451bb5aef0733f6fb5c5b95d33a31e04f5462 (patch) | |
tree | b207d088239f44ed3eb150e10160409f6f6591d3 /test/parallel/test-crypto-hash.js | |
parent | 7097212cb619457e06036eac84e529899c3fd0f9 (diff) | |
download | android-node-v8-1d9451bb5aef0733f6fb5c5b95d33a31e04f5462.tar.gz android-node-v8-1d9451bb5aef0733f6fb5c5b95d33a31e04f5462.tar.bz2 android-node-v8-1d9451bb5aef0733f6fb5c5b95d33a31e04f5462.zip |
crypto: better error message for createHash
calling digest or update on a hash object after digest has been called
now gives a topical error message instead of an error message saying that the
hash failed to initialize.
PR-URL: https://github.com/nodejs/node/pull/6042
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-crypto-hash.js')
-rw-r--r-- | test/parallel/test-crypto-hash.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/parallel/test-crypto-hash.js b/test/parallel/test-crypto-hash.js index fce11eca04..b5fc7e881c 100644 --- a/test/parallel/test-crypto-hash.js +++ b/test/parallel/test-crypto-hash.js @@ -98,3 +98,15 @@ assert.equal( assert.notEqual( hutf8, crypto.createHash('sha512').update('УТФ-8 text', 'binary').digest('hex')); + +var h3 = crypto.createHash('sha256'); +h3.digest(); +assert.throws(function() { + h3.digest(); +}, + /Digest already called/); + +assert.throws(function() { + h3.update('foo'); +}, + /Digest already called/); |