summaryrefslogtreecommitdiff
path: root/cli/tests/unit_node/internal/_randomFill_test.ts
diff options
context:
space:
mode:
authorLevente Kurusa <lkurusa@kernelstuff.org>2023-04-12 02:57:57 +0200
committerGitHub <noreply@github.com>2023-04-12 02:57:57 +0200
commit65b0d2316d9c05c12eccd4bb7821598af3085ad0 (patch)
tree8452365cbb20b3d9992afe9b2c7095a430e6b277 /cli/tests/unit_node/internal/_randomFill_test.ts
parent8820f6e922d3332d0fdd035b504897503d4cdf3a (diff)
refactor(node/crypto): port polyfill to Rust for randomInt, randomFill, randomFillSync (#18658)
Pretty much as per the title, I'd welcome some feedback especially around the array/buffer handling in the two randomFill functions.
Diffstat (limited to 'cli/tests/unit_node/internal/_randomFill_test.ts')
-rw-r--r--cli/tests/unit_node/internal/_randomFill_test.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/cli/tests/unit_node/internal/_randomFill_test.ts b/cli/tests/unit_node/internal/_randomFill_test.ts
index 00ff029cc..5e2e154c8 100644
--- a/cli/tests/unit_node/internal/_randomFill_test.ts
+++ b/cli/tests/unit_node/internal/_randomFill_test.ts
@@ -6,6 +6,7 @@ import {
assertNotEquals,
assertThrows,
} from "../../../../test_util/std/testing/asserts.ts";
+import { deferred } from "../../../../test_util/std/async/deferred.ts";
const validateNonZero = (buf: Buffer) => {
if (!buf.some((ch) => ch > 0)) throw new Error("Error");
@@ -15,14 +16,18 @@ const validateZero = (buf: Buffer) => {
buf.forEach((val) => assertEquals(val, 0));
};
-Deno.test("[node/crypto.randomFill]", () => {
+Deno.test("[node/crypto.randomFill]", async () => {
+ const promise = deferred();
const buf = Buffer.alloc(10);
const before = buf.toString("hex");
randomFill(buf, 5, 5, (_err, bufTwo) => {
const after = bufTwo?.toString("hex");
assertEquals(before.slice(0, 10), after?.slice(0, 10));
+ promise.resolve(true);
});
+
+ await promise;
});
Deno.test("[node/crypto.randomFillSync]", () => {