From 75a724890d94267a02bd431f98d3d7d5866d95e7 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Sat, 23 Sep 2023 13:34:55 +0530 Subject: fix(node): supported arguments to `randomFillSync` (#20637) Fixes https://github.com/denoland/deno/issues/20634 --- cli/tests/unit_node/crypto/crypto_hash_test.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'cli') diff --git a/cli/tests/unit_node/crypto/crypto_hash_test.ts b/cli/tests/unit_node/crypto/crypto_hash_test.ts index e140765ec..4b0aedf03 100644 --- a/cli/tests/unit_node/crypto/crypto_hash_test.ts +++ b/cli/tests/unit_node/crypto/crypto_hash_test.ts @@ -1,5 +1,11 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -import { createHash, createHmac, getHashes, randomUUID } from "node:crypto"; +import { + createHash, + createHmac, + getHashes, + randomFillSync, + randomUUID, +} from "node:crypto"; import { Buffer } from "node:buffer"; import { Readable } from "node:stream"; import { @@ -124,3 +130,13 @@ Deno.test("[node/crypto.getRandomUUID] works the same way as Web Crypto API", () assertEquals(randomUUID().length, crypto.randomUUID().length); assertEquals(typeof randomUUID(), typeof crypto.randomUUID()); }); + +Deno.test("[node/crypto.randomFillSync] supported arguments", () => { + const buf = new Uint8Array(10); + + assert(randomFillSync(buf)); + assert(randomFillSync(buf, 0)); + // @ts-ignore: arraybuffer arguments are valid. + assert(randomFillSync(buf.buffer)); + assert(randomFillSync(new DataView(buf.buffer))); +}); -- cgit v1.2.3