Skip to content

Commit

Permalink
test: add crypto.scrypt test case with different encoding
Browse files Browse the repository at this point in the history
PR-URL: #23578
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
yitongding authored and jasnell committed Oct 17, 2018
1 parent 96c1dd4 commit 0d92159
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/parallel/test-crypto-scrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,24 @@ for (const options of toobig) {
}));
}

{
const defaultEncoding = crypto.DEFAULT_ENCODING;
const defaults = { N: 16384, p: 1, r: 8 };
const expected = crypto.scryptSync('pass', 'salt', 1, defaults);

const testEncoding = 'latin1';
crypto.DEFAULT_ENCODING = testEncoding;
const actual = crypto.scryptSync('pass', 'salt', 1);
assert.deepStrictEqual(actual, expected.toString(testEncoding));

crypto.scrypt('pass', 'salt', 1, common.mustCall((err, actual) => {
assert.ifError(err);
assert.deepStrictEqual(actual, expected.toString(testEncoding));
}));

crypto.DEFAULT_ENCODING = defaultEncoding;
}

for (const { args, expected } of badargs) {
common.expectsError(() => crypto.scrypt(...args), expected);
common.expectsError(() => crypto.scryptSync(...args), expected);
Expand Down

0 comments on commit 0d92159

Please sign in to comment.