From 4b890e95d63f7846f430329ea586a033aab7e334 Mon Sep 17 00:00:00 2001 From: Yitong Date: Fri, 12 Oct 2018 11:16:33 -0700 Subject: [PATCH] test: add crypto.scrypt test case with different encoding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/23578 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Tobias Nießen Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater --- test/parallel/test-crypto-scrypt.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/parallel/test-crypto-scrypt.js b/test/parallel/test-crypto-scrypt.js index 982b0ac6d5b640..908179b46e3071 100644 --- a/test/parallel/test-crypto-scrypt.js +++ b/test/parallel/test-crypto-scrypt.js @@ -187,6 +187,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);