Skip to content

Commit

Permalink
Improve test structure
Browse files Browse the repository at this point in the history
  • Loading branch information
gndelia committed Jan 8, 2025
1 parent 6e82301 commit 15507a7
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .knip.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"entry": ["src/index.ts", "src/contracts/index.ts"],
"ignore": [".eslintrc.json"]
"entry": ["src/index.ts!", "src/contracts/index.ts!"],
"project": ["src/**/*.ts!", "!src/test/**!"]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build:esm": "tsc --noEmit false --outDir ./_esm --sourceMap",
"build:types": "tsc --module esnext --declarationDir ./_types --emitDeclarationOnly --declaration --declarationMap",
"clean": "rm -rf ./_esm ./_cjs ./_types",
"deps:check": "knip",
"deps:check": "knip --production --tags=-knipignore",
"format:check": "prettier --check .",
"lint": "eslint --cache .",
"prepare": "husky",
Expand Down
6 changes: 1 addition & 5 deletions src/utils/withdrawals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
export const getWithdrawalVaultUUID = (uuid: bigint) =>
uuid & BigInt(0x00000000ffffffff);

/**
* Gets the Vault index associated to the Withdrawal.
* @param uuid The withdrawal UUID
* @returns The vault UUID.
*/
/** @knipignore */
export const getVaultUUID = (uuid: bigint) =>
(uuid & BigInt(0xffffffff00000000)) >> BigInt(32);
21 changes: 0 additions & 21 deletions test/utils/withdrawals.test.js

This file was deleted.

21 changes: 21 additions & 0 deletions test/utils/withdrawals.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { getWithdrawalVaultUUID, getVaultUUID } from "src/utils/withdrawals";
import { describe, it, expect } from "vitest";

const uuid = BigInt(17179869217); // Hex is 0x400000021

describe("src/utils/withdrawals", function () {
describe("getWithdrawalVaultUUID", function () {
it("should return the lower 32 bits of the UUID", function () {
const result = getWithdrawalVaultUUID(uuid);
// 21 in hex is 33 in decimal
expect(result).toBe(BigInt(33));
});
});

describe("getVaultUUID", function () {
it("should return the upper 32 bits of the UUID", function () {
const result = getVaultUUID(uuid);
expect(result).toBe(BigInt(4));
});
});
});

0 comments on commit 15507a7

Please sign in to comment.