aboutsummaryrefslogtreecommitdiff
path: root/test/bun.js/node-crypto.test.js
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-19 20:28:34 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-01-19 20:28:34 -0800
commit4c0b0e2e8ee3a2710ea3d5b3711efc905f6f2be5 (patch)
tree8a559a3eba5b1f6d1f0ece48f1619f1d752a58dc /test/bun.js/node-crypto.test.js
parentbab7e63d7cf928460c34c8bf438fc167fe5e7b31 (diff)
downloadbun-4c0b0e2e8ee3a2710ea3d5b3711efc905f6f2be5.tar.gz
bun-4c0b0e2e8ee3a2710ea3d5b3711efc905f6f2be5.tar.zst
bun-4c0b0e2e8ee3a2710ea3d5b3711efc905f6f2be5.zip
Fix buffer encoding bug
Diffstat (limited to 'test/bun.js/node-crypto.test.js')
-rw-r--r--test/bun.js/node-crypto.test.js15
1 files changed, 12 insertions, 3 deletions
diff --git a/test/bun.js/node-crypto.test.js b/test/bun.js/node-crypto.test.js
index edd6f6e3d..227368760 100644
--- a/test/bun.js/node-crypto.test.js
+++ b/test/bun.js/node-crypto.test.js
@@ -1,8 +1,17 @@
import { it, expect } from "bun:test";
-const nodeCrypto = require("node:crypto");
+import crypto from "node:crypto";
it("crypto.randomBytes should return a Buffer", () => {
- expect(nodeCrypto.randomBytes(1) instanceof Buffer).toBe(true);
- expect(Buffer.isBuffer(nodeCrypto.randomBytes(1))).toBe(true);
+ expect(crypto.randomBytes(1) instanceof Buffer).toBe(true);
+ expect(Buffer.isBuffer(crypto.randomBytes(1))).toBe(true);
+});
+
+// https://github.com/oven-sh/bun/issues/1839
+it("crypto.createHash ", () => {
+ function fn() {
+ crypto.createHash("sha1").update(Math.random(), "ascii").digest("base64");
+ }
+
+ for (let i = 0; i < 10; i++) fn();
});