summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2023-09-23 13:34:55 +0530
committerGitHub <noreply@github.com>2023-09-23 10:04:55 +0200
commit75a724890d94267a02bd431f98d3d7d5866d95e7 (patch)
treeeff10e783aaeb9e4dca6af76e1872ed877413d78 /cli/tests
parent365d1ac7c2c6e81cbc32135ed6a099f3caaa6110 (diff)
fix(node): supported arguments to `randomFillSync` (#20637)
Fixes https://github.com/denoland/deno/issues/20634
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/unit_node/crypto/crypto_hash_test.ts18
1 files changed, 17 insertions, 1 deletions
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)));
+});