Skip to content

Commit

Permalink
refactor MudV2Test to avoid circular dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dk1a committed Jun 21, 2023
1 parent f8b06ba commit 8bb1aea
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 29 deletions.
10 changes: 5 additions & 5 deletions docs/pages/world/world-101.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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");
}
Expand Down
1 change: 0 additions & 1 deletion e2e/packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions e2e/packages/contracts/test/Worldgen.t.sol
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
3 changes: 0 additions & 3 deletions e2e/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion examples/minimal/packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions examples/minimal/packages/contracts/test/ChatNamespaced.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
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";

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);
Expand Down
4 changes: 2 additions & 2 deletions examples/minimal/packages/contracts/test/CounterTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
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 { SingletonKey } from "../src/systems/IncrementSystem.sol";

contract CounterTest is MudV2Test {
contract CounterTest is MudTest {
IWorld world;

function setUp() public override {
Expand Down
4 changes: 2 additions & 2 deletions examples/minimal/packages/contracts/test/StructTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions examples/minimal/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion packages/std-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8bb1aea

Please sign in to comment.