Skip to content

Commit

Permalink
move store ts test to monorepo root
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Oct 6, 2024
1 parent c46145e commit 908c0e6
Show file tree
Hide file tree
Showing 16 changed files with 666 additions and 144 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@
"@types/node": "^18.15.11",
"@typescript-eslint/eslint-plugin": "7.1.1",
"@typescript-eslint/parser": "7.1.1",
"@viem/anvil": "^0.0.7",
"chalk": "^5.2.0",
"eslint": "8.57.0",
"execa": "^7.0.0",
"execa": "^9.4.0",
"glob": "^10.4.2",
"husky": ">=6",
"lint-staged": "^15.2.10",
Expand All @@ -54,7 +55,9 @@
"sort-package-json": "^2.10.1",
"tsx": "4.16.2",
"turbo": "^1.9.3",
"typescript": "5.4.2"
"typescript": "5.4.2",
"viem": "catalog:",
"vitest": "2.1.2"
},
"packageManager": "[email protected]",
"engines": {
Expand Down
1 change: 1 addition & 0 deletions packages/config/src/exports/internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Nothing here yet.
5 changes: 1 addition & 4 deletions packages/store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,11 @@
"@latticexyz/gas-report": "workspace:*",
"@types/debug": "^4.1.7",
"@types/ejs": "^3.1.1",
"@types/mocha": "^9.1.1",
"@types/node": "^18.15.11",
"@viem/anvil": "^0.0.7",
"ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
"forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1",
"solhint": "^3.3.7",
"tsup": "^6.7.0",
"tsx": "^3.12.6",
"vitest": "0.34.6"
"tsx": "^3.12.6"
}
}
15 changes: 9 additions & 6 deletions packages/store/ts/flattenStoreLogs.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
/* eslint-disable max-len */
import { beforeAll, describe, expect, it } from "vitest";
import { deployMockGame } from "./test/mockGame";
import { testClient } from "./test/common";
import { beforeAll, beforeEach, describe, expect, it } from "vitest";
import { getStoreLogs } from "./getStoreLogs";
import { summarizeLogs } from "./test/summarizeLogs";
import { flattenStoreLogs } from "./flattenStoreLogs";
import { snapshotAnvilState, testClient } from "../../../test-setup/common";
import { deployMockGame } from "../../../test-setup/mockGame";
import { summarizeLogs } from "./test/summarizeLogs";

describe("flattenStoreLogs", async () => {
beforeAll(async () => {
const resetAnvilState = await snapshotAnvilState();
await deployMockGame();
return resetAnvilState;
});
beforeEach(snapshotAnvilState);

it("flattens store logs", async () => {
const logs = await getStoreLogs(testClient, { fromBlock: "earliest", toBlock: "latest" });
Expand Down Expand Up @@ -132,8 +135,8 @@ describe("flattenStoreLogs", async () => {
"Store_SetRecord store__ResourceIds (0x746200000000000000000000000000005465727261696e000000000000000000)",
"Store_SetRecord store__ResourceIds (0x737900000000000000000000000000004d6f766553797374656d000000000000)",
"Store_SetRecord world__Systems (0x737900000000000000000000000000004d6f766553797374656d000000000000)",
"Store_SetRecord world__SystemRegistry (0x000000000000000000000000b7b226e8dc03ee1e9c28eb37309c1c48dd5d88f3)",
"Store_SetRecord world__ResourceAccess (0x6e73000000000000000000000000000000000000000000000000000000000000,0x000000000000000000000000b7b226e8dc03ee1e9c28eb37309c1c48dd5d88f3)",
"Store_SetRecord world__SystemRegistry (0x000000000000000000000000909d87ff2af6abace4fe66171b9622bc10305c3c)",
"Store_SetRecord world__ResourceAccess (0x6e73000000000000000000000000000000000000000000000000000000000000,0x000000000000000000000000909d87ff2af6abace4fe66171b9622bc10305c3c)",
"Store_SetRecord world__FunctionSelector (0xb591186e00000000000000000000000000000000000000000000000000000000)",
"Store_SetRecord world__FunctionSignatur (0xb591186e00000000000000000000000000000000000000000000000000000000)",
"Store_SetRecord store__Tables (0x7462000000000000000000000000000043616c6c576974685369676e61747572)",
Expand Down
13 changes: 8 additions & 5 deletions packages/store/ts/getStoreLogs.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
/* eslint-disable max-len */
import { beforeAll, describe, expect, it } from "vitest";
import { deployMockGame } from "./test/mockGame";
import { testClient } from "./test/common";
import { beforeAll, beforeEach, describe, expect, it } from "vitest";
import { getStoreLogs } from "./getStoreLogs";
import config from "../mud.config";
import { snapshotAnvilState, testClient } from "../../../test-setup/common";
import { deployMockGame } from "../../../test-setup/mockGame";
import { summarizeLogs } from "./test/summarizeLogs";

describe("getStoreLogs", async () => {
beforeAll(async () => {
const resetAnvilState = await snapshotAnvilState();
await deployMockGame();
return resetAnvilState;
});
beforeEach(snapshotAnvilState);

it("fetches only store logs", async () => {
const logs = await getStoreLogs(testClient, { fromBlock: "earliest", toBlock: "latest" });
Expand Down Expand Up @@ -155,8 +158,8 @@ describe("getStoreLogs", async () => {
"Store_SpliceStaticData store__ResourceIds (0x746200000000000000000000000000005465727261696e000000000000000000)",
"Store_SpliceStaticData store__ResourceIds (0x737900000000000000000000000000004d6f766553797374656d000000000000)",
"Store_SetRecord world__Systems (0x737900000000000000000000000000004d6f766553797374656d000000000000)",
"Store_SpliceStaticData world__SystemRegistry (0x000000000000000000000000b7b226e8dc03ee1e9c28eb37309c1c48dd5d88f3)",
"Store_SpliceStaticData world__ResourceAccess (0x6e73000000000000000000000000000000000000000000000000000000000000,0x000000000000000000000000b7b226e8dc03ee1e9c28eb37309c1c48dd5d88f3)",
"Store_SpliceStaticData world__SystemRegistry (0x000000000000000000000000909d87ff2af6abace4fe66171b9622bc10305c3c)",
"Store_SpliceStaticData world__ResourceAccess (0x6e73000000000000000000000000000000000000000000000000000000000000,0x000000000000000000000000909d87ff2af6abace4fe66171b9622bc10305c3c)",
"Store_SetRecord world__FunctionSelector (0xb591186e00000000000000000000000000000000000000000000000000000000)",
"Store_SetRecord world__FunctionSignatur (0xb591186e00000000000000000000000000000000000000000000000000000000)",
"Store_SetRecord world__FunctionSignatur (0xb591186e00000000000000000000000000000000000000000000000000000000)",
Expand Down
4 changes: 3 additions & 1 deletion packages/store/ts/protocolVersions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import { protocolVersions } from "./protocolVersions";

const [, currentVersion] = fs.readFileSync(`${__dirname}/../src/version.sol`, "utf8").match(/VERSION = "(.*?)"/) ?? [];

const currentAbi = formatAbi(StoreAbi).sort((a, b) => a.localeCompare(b));
const currentAbi = formatAbi(StoreAbi)
.slice()
.sort((a, b) => a.localeCompare(b));

describe("Store protocol version", () => {
it("is up to date", async () => {
Expand Down
1 change: 0 additions & 1 deletion packages/world-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"@latticexyz/cli": "workspace:*",
"@latticexyz/gas-report": "workspace:*",
"@types/ejs": "^3.1.1",
"@types/mocha": "^9.1.1",
"@types/node": "^18.15.11",
"ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
"forge-std": "https://github.com/foundry-rs/forge-std.git#74cfb77e308dd188d2f58864aaf44963ae6b88b1",
Expand Down
1 change: 0 additions & 1 deletion packages/world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"@latticexyz/gas-report": "workspace:*",
"@types/debug": "^4.1.7",
"@types/ejs": "^3.1.1",
"@types/mocha": "^9.1.1",
"@types/node": "^18.15.11",
"ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",
"ejs": "^3.1.10",
Expand Down
Loading

0 comments on commit 908c0e6

Please sign in to comment.