From 8bb1aeacd8ff8c8b7feaa261a8a60f4b848526b3 Mon Sep 17 00:00:00 2001 From: dk1a Date: Wed, 21 Jun 2023 18:00:09 +0300 Subject: [PATCH] refactor MudV2Test to avoid circular dependencies --- docs/pages/world/world-101.mdx | 10 +++++----- e2e/packages/contracts/package.json | 1 - e2e/packages/contracts/test/Worldgen.t.sol | 4 ++-- e2e/pnpm-lock.yaml | 3 --- examples/minimal/packages/contracts/package.json | 1 - .../packages/contracts/test/ChatNamespaced.t.sol | 4 ++-- .../minimal/packages/contracts/test/CounterTest.t.sol | 4 ++-- .../minimal/packages/contracts/test/StructTest.t.sol | 4 ++-- examples/minimal/pnpm-lock.yaml | 5 +---- packages/std-contracts/package.json | 1 - .../src/test/MudV2Test.t.sol => store/src/MudTest.sol} | 6 +++--- pnpm-lock.yaml | 3 --- 12 files changed, 17 insertions(+), 29 deletions(-) rename packages/{std-contracts/src/test/MudV2Test.t.sol => store/src/MudTest.sol} (65%) diff --git a/docs/pages/world/world-101.mdx b/docs/pages/world/world-101.mdx index 228d186b72..e958aa5891 100644 --- a/docs/pages/world/world-101.mdx +++ b/docs/pages/world/world-101.mdx @@ -256,11 +256,11 @@ Create a new file named `MySystemTest.t.sol` in the `test` folder. pragma solidity >=0.8.0; import "forge-std/Test.sol"; -import { MudV2Test } from "@latticexyz/std-contracts/src/test/MudV2Test.t.sol"; +import { MudTest } from "@latticexyz/store/src/MudTest.sol"; import { IWorld } from "../src/codegen/world/IWorld.sol"; import { Dog, DogId } from "../src/codegen/Tables.sol"; -contract MySystemTest is MudV2Test { +contract MySystemTest is MudTest { IWorld world; function setUp() public override { @@ -271,10 +271,10 @@ contract MySystemTest is MudV2Test { function testAddEntry() public { // Add a new entry to the Dog via the system // this will call the addEntry function on MySystem - bytes32 key = World.addEntry("bob", "blue"); + bytes32 key = world.addEntry("bob", "blue"); // Expect the value retrieved from the Dog at the corresponding key to match "bob" and "blue" - string memory name = Dog.getName(world, key); - string memory color = Dog.getColor(world, key); + string memory name = Dog.getName(key); + string memory color = Dog.getColor(key); assertEq(name, "bob"); assertEq(color, "blue"); } diff --git a/e2e/packages/contracts/package.json b/e2e/packages/contracts/package.json index f454a2bd9a..29a1b1bf8d 100644 --- a/e2e/packages/contracts/package.json +++ b/e2e/packages/contracts/package.json @@ -20,7 +20,6 @@ "@latticexyz/cli": "link:../../../packages/cli", "@latticexyz/config": "link:../../../packages/config", "@latticexyz/schema-type": "link:../../../packages/schema-type", - "@latticexyz/std-contracts": "link:../../../packages/std-contracts", "@latticexyz/store": "link:../../../packages/store", "@latticexyz/world": "link:../../../packages/world", "@typechain/ethers-v5": "^10.2.0", diff --git a/e2e/packages/contracts/test/Worldgen.t.sol b/e2e/packages/contracts/test/Worldgen.t.sol index 631e342644..2b2c88565e 100644 --- a/e2e/packages/contracts/test/Worldgen.t.sol +++ b/e2e/packages/contracts/test/Worldgen.t.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.0; -import { MudV2Test } from "@latticexyz/std-contracts/src/test/MudV2Test.t.sol"; +import { MudTest } from "@latticexyz/store/src/MudTest.sol"; import { ICustomErrorsSystem } from "../src/codegen/world/ICustomErrorsSystem.sol"; import { Position } from "../src/CustomTypes.sol"; -contract WorldgenTest is MudV2Test { +contract WorldgenTest is MudTest { function testError1WasGenerated() public { vm.expectRevert(); revert ICustomErrorsSystem.TestError1(); diff --git a/e2e/pnpm-lock.yaml b/e2e/pnpm-lock.yaml index 882378b586..d13663a39b 100644 --- a/e2e/pnpm-lock.yaml +++ b/e2e/pnpm-lock.yaml @@ -104,9 +104,6 @@ importers: '@latticexyz/schema-type': specifier: link:../../../packages/schema-type version: link:../../../packages/schema-type - '@latticexyz/std-contracts': - specifier: link:../../../packages/std-contracts - version: link:../../../packages/std-contracts '@latticexyz/store': specifier: link:../../../packages/store version: link:../../../packages/store diff --git a/examples/minimal/packages/contracts/package.json b/examples/minimal/packages/contracts/package.json index 5fcd510bc4..dbdc13c5b6 100644 --- a/examples/minimal/packages/contracts/package.json +++ b/examples/minimal/packages/contracts/package.json @@ -26,7 +26,6 @@ "@latticexyz/config": "link:../../../../packages/config", "@latticexyz/schema-type": "link:../../../../packages/schema-type", "@latticexyz/solecs": "link:../../../../packages/solecs", - "@latticexyz/std-contracts": "link:../../../../packages/std-contracts", "@latticexyz/store": "link:../../../../packages/store", "@latticexyz/world": "link:../../../../packages/world", "@solidstate/contracts": "^0.0.52", diff --git a/examples/minimal/packages/contracts/test/ChatNamespaced.t.sol b/examples/minimal/packages/contracts/test/ChatNamespaced.t.sol index c7dfa0ff9e..c98a25a337 100644 --- a/examples/minimal/packages/contracts/test/ChatNamespaced.t.sol +++ b/examples/minimal/packages/contracts/test/ChatNamespaced.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import "forge-std/Test.sol"; -import { MudV2Test } from "@latticexyz/std-contracts/src/test/MudV2Test.t.sol"; +import { MudTest } from "@latticexyz/store/src/MudTest.sol"; import { getKeysWithValue } from "@latticexyz/world/src/modules/keyswithvalue/getKeysWithValue.sol"; import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; @@ -10,7 +10,7 @@ import { IWorld } from "../src/codegen/world/IWorld.sol"; import { MessageTable, MessageTableTableId } from "../src/codegen/Tables.sol"; import { IChatNamespacedSystem } from "../src/interfaces/IChatNamespacedSystem.sol"; -contract ChatNamespacedTest is MudV2Test { +contract ChatNamespacedTest is MudTest { function testEmitEphemeral() public { bytes32[] memory keyTuple; vm.expectEmit(true, true, true, true); diff --git a/examples/minimal/packages/contracts/test/CounterTest.t.sol b/examples/minimal/packages/contracts/test/CounterTest.t.sol index 13da16031c..a71bc1fc4e 100644 --- a/examples/minimal/packages/contracts/test/CounterTest.t.sol +++ b/examples/minimal/packages/contracts/test/CounterTest.t.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import "forge-std/Test.sol"; -import { MudV2Test } from "@latticexyz/std-contracts/src/test/MudV2Test.t.sol"; +import { MudTest } from "@latticexyz/store/src/MudTest.sol"; import { getKeysWithValue } from "@latticexyz/world/src/modules/keyswithvalue/getKeysWithValue.sol"; import { IWorld } from "../src/codegen/world/IWorld.sol"; @@ -10,7 +10,7 @@ import { CounterTable, CounterTableTableId } from "../src/codegen/Tables.sol"; import { SingletonKey } from "../src/systems/IncrementSystem.sol"; -contract CounterTest is MudV2Test { +contract CounterTest is MudTest { IWorld world; function setUp() public override { diff --git a/examples/minimal/packages/contracts/test/StructTest.t.sol b/examples/minimal/packages/contracts/test/StructTest.t.sol index 8b4f85a57d..d18f842a4f 100644 --- a/examples/minimal/packages/contracts/test/StructTest.t.sol +++ b/examples/minimal/packages/contracts/test/StructTest.t.sol @@ -2,14 +2,14 @@ pragma solidity >=0.8.0; import "forge-std/Test.sol"; -import { MudV2Test } from "@latticexyz/std-contracts/src/test/MudV2Test.t.sol"; +import { MudTest } from "@latticexyz/store/src/MudTest.sol"; import { getKeysWithValue } from "@latticexyz/world/src/modules/keyswithvalue/getKeysWithValue.sol"; import { IWorld } from "../src/codegen/world/IWorld.sol"; import { CounterTable, CounterTableTableId } from "../src/codegen/Tables.sol"; import { BytesStruct, StringStruct } from "../src/systems/structs.sol"; -contract StructTest is MudV2Test { +contract StructTest is MudTest { IWorld world; function setUp() public override { diff --git a/examples/minimal/pnpm-lock.yaml b/examples/minimal/pnpm-lock.yaml index 7c3f69dd4e..5ee3e1749c 100644 --- a/examples/minimal/pnpm-lock.yaml +++ b/examples/minimal/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: autoInstallPeers: true @@ -356,9 +356,6 @@ importers: '@latticexyz/solecs': specifier: link:../../../../packages/solecs version: link:../../../../packages/solecs - '@latticexyz/std-contracts': - specifier: link:../../../../packages/std-contracts - version: link:../../../../packages/std-contracts '@latticexyz/store': specifier: link:../../../../packages/store version: link:../../../../packages/store diff --git a/packages/std-contracts/package.json b/packages/std-contracts/package.json index 01018f6830..6c9235f24e 100644 --- a/packages/std-contracts/package.json +++ b/packages/std-contracts/package.json @@ -22,7 +22,6 @@ }, "devDependencies": { "@latticexyz/solecs": "workspace:*", - "@latticexyz/store": "workspace:*", "@solidstate/contracts": "^0.0.52", "@typechain/ethers-v5": "^10.2.0", "ds-test": "https://github.com/dapphub/ds-test.git#c9ce3f25bde29fc5eb9901842bf02850dfd2d084", diff --git a/packages/std-contracts/src/test/MudV2Test.t.sol b/packages/store/src/MudTest.sol similarity index 65% rename from packages/std-contracts/src/test/MudV2Test.t.sol rename to packages/store/src/MudTest.sol index f29a514e56..9ca7df7a3e 100644 --- a/packages/std-contracts/src/test/MudV2Test.t.sol +++ b/packages/store/src/MudTest.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.0; -import "forge-std/Test.sol"; -import { IStoreConsumer } from "@latticexyz/store/src/StoreConsumer.sol"; +import { Test } from "forge-std/Test.sol"; +import { IStoreConsumer } from "./StoreConsumer.sol"; -contract MudV2Test is Test, IStoreConsumer { +contract MudTest is Test, IStoreConsumer { address worldAddress; function setUp() public virtual { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 912aaaea56..a4b8268ae1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -880,9 +880,6 @@ importers: '@latticexyz/solecs': specifier: workspace:* version: link:../solecs - '@latticexyz/store': - specifier: workspace:* - version: link:../store '@solidstate/contracts': specifier: ^0.0.52 version: 0.0.52