refactor(node/crypto): scrypt polyfill to rust (#18746)

This commit is contained in:
Levente Kurusa 2023-04-18 14:29:10 +02:00 committed by GitHub
parent 74aee8b305
commit 530963c34c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 167 additions and 179 deletions

View file

@ -2,8 +2,11 @@
import { scrypt, scryptSync } from "node:crypto";
import { Buffer } from "node:buffer";
import { assertEquals } from "../../../../test_util/std/testing/asserts.ts";
import { deferred } from "../../../../test_util/std/async/deferred.ts";
Deno.test("scrypt works correctly", async () => {
const promise = deferred();
Deno.test("scrypt works correctly", () => {
scrypt("password", "salt", 32, (err, key) => {
if (err) throw err;
assertEquals(
@ -43,10 +46,15 @@ Deno.test("scrypt works correctly", () => {
115,
]),
);
promise.resolve(true);
});
await promise;
});
Deno.test("scrypt works with options", () => {
Deno.test("scrypt works with options", async () => {
const promise = deferred();
scrypt(
"password",
"salt",
@ -93,8 +101,11 @@ Deno.test("scrypt works with options", () => {
71,
]),
);
promise.resolve(true);
},
);
await promise;
});
Deno.test("scryptSync works correctly", () => {