From 098b4b5ddf072218897be27609946bd459be7683 Mon Sep 17 00:00:00 2001 From: alvrs Date: Mon, 26 Sep 2022 10:26:51 +0100 Subject: [PATCH] test: add MoveSystemTest --- .../src/test/systems/GameConfigSystem.t.sol | 28 ------------------- .../src/test/systems/MoveSystem.t.sol | 18 ++++++++++++ 2 files changed, 18 insertions(+), 28 deletions(-) delete mode 100644 packages/contracts/src/test/systems/GameConfigSystem.t.sol create mode 100644 packages/contracts/src/test/systems/MoveSystem.t.sol diff --git a/packages/contracts/src/test/systems/GameConfigSystem.t.sol b/packages/contracts/src/test/systems/GameConfigSystem.t.sol deleted file mode 100644 index 10228bd0..00000000 --- a/packages/contracts/src/test/systems/GameConfigSystem.t.sol +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: Unlicense -pragma solidity >=0.8.0; - -import "../MudTest.t.sol"; - -contract GameConfigSystemTest is MudTest { - function testExecute() public { - vm.startPrank(deployer); - console.log("Depiloyer"); - console.log(deployer); - // GameConfigSystem(system(sysID)).execute(new bytes(0)); - // GameConfigComponent gameConfigComponent = GameConfigComponent(component(compID)); - // assertTrue(gameConfigComponent.getRawValue(GodID).length != 0); - vm.stopPrank(); - } - - function testRequirement() public { - vm.startPrank(deployer); - // GameConfigSystem(system(sysID)).requirement(new bytes(0)); - vm.stopPrank(); - } - - function testFailRequirement() public { - vm.startPrank(alice); - // GameConfigSystem(system(sysID)).requirement(new bytes(0)); - vm.stopPrank(); - } -} diff --git a/packages/contracts/src/test/systems/MoveSystem.t.sol b/packages/contracts/src/test/systems/MoveSystem.t.sol new file mode 100644 index 00000000..d89db18d --- /dev/null +++ b/packages/contracts/src/test/systems/MoveSystem.t.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: Unlicense +pragma solidity >=0.8.0; + +import "../MudTest.t.sol"; +import { MoveSystem, ID as MoveSystemID } from "../../systems/MoveSystem.sol"; +import { PositionComponent, ID as PositionComponentID, Coord } from "../../components/PositionComponent.sol"; + +contract MoveSystemTest is MudTest { + function testExecute() public { + uint256 entity = 1; + Coord memory coord = Coord(12, 34); + MoveSystem(system(MoveSystemID)).executeTyped(entity, coord); + PositionComponent positionComponent = PositionComponent(component(PositionComponentID)); + Coord memory position = positionComponent.getValue(entity); + assertEq(position.x, coord.x); + assertEq(position.y, coord.y); + } +}