Skip to content

Commit d0a61fa

Browse files
committed
Update tests setup
+ remove polyfill crypto + use predefined sha256 instead of use createHash function
1 parent 18be25a commit d0a61fa

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

test/config/chrome.config.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { nodePolyfills } from "vite-plugin-node-polyfills";
44
import { defineConfig } from "vitest/config";
55

66
export default defineConfig({
7-
plugins: [nodePolyfills({ include: ["crypto", "util", "stream"] })],
7+
plugins: [nodePolyfills({ include: ["buffer"] })],
88
test: {
99
reporters: "verbose",
1010
browser: {

test/config/firefox.config.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { nodePolyfills } from "vite-plugin-node-polyfills";
44
import { defineConfig } from "vitest/config";
55

66
export default defineConfig({
7-
plugins: [nodePolyfills({ include: ["crypto", "util", "stream"] })],
7+
plugins: [nodePolyfills({ include: ["buffer"] })],
88
test: {
99
reporters: "verbose",
1010
browser: {

test/config/safari.config.mts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { nodePolyfills } from "vite-plugin-node-polyfills";
44
import { defineConfig } from "vitest/config";
55

66
export default defineConfig({
7-
plugins: [nodePolyfills({ include: ["crypto", "util", "stream"] })],
7+
plugins: [nodePolyfills({ include: ["buffer"] })],
88
test: {
99
reporters: "verbose",
1010
browser: {

test/sign&verify.spec.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
/* eslint-disable import/no-extraneous-dependencies */
2-
import { createHash } from "crypto";
32
import { beforeEach, describe, expect, it } from "vitest";
43

54
import * as eccrypto from "../src/index";
6-
const msg = createHash("sha256").update("test").digest();
5+
// msgString is the sha256 hash of "test"
6+
const msgString = "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08";
7+
const msg = Buffer.from(msgString, "hex");
78

89
describe("Functions: sign & verify", () => {
910
let privKey: Buffer;

0 commit comments

Comments
 (0)