Skip to content

Commit

Permalink
Fix unit tests for deno
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarhussain committed Nov 21, 2024
1 parent e541df3 commit 454956a
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/as-sha256/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"url": "git+https://github.com/chainsafe/ssz.git"
},
"main": "lib/index.js",
"deno": "src/index.ts",
"typesVersions": {
"*": {
"*": [
Expand Down
1 change: 1 addition & 0 deletions packages/persistent-merkle-tree/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.8.0",
"description": "Merkle tree implemented as a persistent datastructure",
"main": "lib/index.js",
"deno": "src/index.ts",
"typesVersions": {
"*": {
"*": [
Expand Down
2 changes: 1 addition & 1 deletion packages/persistent-merkle-tree/src/hasher/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {byteArrayToHashObject, HashObject, hashObjectToByteArray} from "@chainsafe/as-sha256/lib/hashObject";
import {byteArrayToHashObject, HashObject, hashObjectToByteArray} from "@chainsafe/as-sha256";
import {zeroHash} from "../zeroHash";

export function hashObjectToUint8Array(obj: HashObject): Uint8Array {
Expand Down
1 change: 1 addition & 0 deletions packages/persistent-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.19.1",
"description": "Persistent data structures for TypeScript.",
"main": "lib/index.js",
"deno": "src/index.ts",
"files": [
"lib/**/*.d.ts",
"lib/**/*.js",
Expand Down
1 change: 1 addition & 0 deletions packages/ssz/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"homepage": "https://github.com/chainsafe/ssz",
"version": "0.18.0",
"main": "lib/index.js",
"deno": "src/index.ts",
"files": [
"lib/**/*.d.ts",
"lib/**/*.js",
Expand Down
5 changes: 2 additions & 3 deletions packages/ssz/src/util/merkleize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {hasher} from "@chainsafe/persistent-merkle-tree/lib/hasher/index";
import {zeroHash} from "@chainsafe/persistent-merkle-tree";
import {zeroHash, digest64} from "@chainsafe/persistent-merkle-tree";

/** Dedicated property to cache hashTreeRoot of immutable CompositeType values */
export const symbolCachedPermanentRoot = Symbol("ssz_cached_permanent_root");
Expand All @@ -10,7 +9,7 @@ export type ValueWithCachedPermanentRoot = {
};

export function hash64(bytes32A: Uint8Array, bytes32B: Uint8Array): Uint8Array {
return hasher.digest64(bytes32A, bytes32B);
return digest64(bytes32A, bytes32B);
}

export function merkleize(chunks: Uint8Array[], padFor: number): Uint8Array {
Expand Down
5 changes: 5 additions & 0 deletions vitest.base.unit.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ function getTestEnvironment(
}

export default defineConfig({
resolve: {
// Adding `deno` field is just for testing purpose.
// Vite validates the package.json and could not find `lib/index.js` in deno runtime
mainFields: ["deno", "main"],
},
test: {
include: ["**/*.test.ts"],
exclude: [
Expand Down

0 comments on commit 454956a

Please sign in to comment.