Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aea09da

Browse filesBrowse files
nhoelgibfahn
authored andcommitted
test: include values in assertion messages
Specifically for the test-crypto-hash.js test file. PR-URL: #15996 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
1 parent ec51688 commit aea09da
Copy full SHA for aea09da

File tree

Expand file treeCollapse file tree

1 file changed

+25
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+25
-7
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-crypto-hash.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-crypto-hash.js
+25-7Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ const fs = require('fs');
99

1010
const fixtures = require('../common/fixtures');
1111

12+
let cryptoType;
13+
let digest;
14+
1215
// Test hashing
1316
const a1 = crypto.createHash('sha1').update('Test123').digest('hex');
1417
const a2 = crypto.createHash('sha256').update('Test123').digest('base64');
@@ -37,16 +40,29 @@ a8.end();
3740
a8 = a8.read();
3841

3942
if (!common.hasFipsCrypto) {
40-
const a0 = crypto.createHash('md5').update('Test123').digest('latin1');
43+
cryptoType = 'md5';
44+
digest = 'latin1';
45+
const a0 = crypto.createHash(cryptoType).update('Test123').digest(digest);
4146
assert.strictEqual(
4247
a0,
4348
'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca\u00bd\u008c',
44-
'Test MD5 as latin1'
49+
`${cryptoType} with ${digest} digest failed to evaluate to expected hash`
4550
);
4651
}
47-
assert.strictEqual(a1, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'Test SHA1');
48-
assert.strictEqual(a2, '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=',
49-
'Test SHA256 as base64');
52+
cryptoType = 'md5';
53+
digest = 'hex';
54+
assert.strictEqual(
55+
a1,
56+
'8308651804facb7b9af8ffc53a33a22d6a1c8ac2',
57+
`${cryptoType} with ${digest} digest failed to evaluate to expected hash`);
58+
cryptoType = 'sha256';
59+
digest = 'base64';
60+
assert.strictEqual(
61+
a2,
62+
'2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=',
63+
`${cryptoType} with ${digest} digest failed to evaluate to expected hash`);
64+
cryptoType = 'sha512';
65+
digest = 'latin1';
5066
assert.deepStrictEqual(
5167
a3,
5268
Buffer.from(
@@ -56,11 +72,13 @@ assert.deepStrictEqual(
5672
'\u00d7\u00d6\u00a2\u00a8\u0085\u00e3<\u0083\u009c\u0093' +
5773
'\u00c2\u0006\u00da0\u00a1\u00879(G\u00ed\'',
5874
'latin1'),
59-
'Test SHA512 as assumed buffer');
75+
`${cryptoType} with ${digest} digest failed to evaluate to expected hash`);
76+
cryptoType = 'sha1';
77+
digest = 'hex';
6078
assert.deepStrictEqual(
6179
a4,
6280
Buffer.from('8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'hex'),
63-
'Test SHA1'
81+
`${cryptoType} with ${digest} digest failed to evaluate to expected hash`
6482
);
6583

6684
// stream interface should produce the same result.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.