Skip to content

Commit

Permalink
refactor(store,world): move test table config out of main table config (
Browse files Browse the repository at this point in the history
  • Loading branch information
alvrs authored Sep 25, 2023
1 parent 63831a2 commit 90e4161
Show file tree
Hide file tree
Showing 30 changed files with 233 additions and 191 deletions.
6 changes: 6 additions & 0 deletions .changeset/curly-numbers-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@latticexyz/store": patch
"@latticexyz/world": patch
---

Moved the test tables out of the main config in `world` and `store` and into their own separate config.
94 changes: 47 additions & 47 deletions packages/store/gas-report.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@
"name": "create bytes32 from bytes memory with offset 16",
"gasUsed": 36
},
{
"file": "test/Callbacks.t.sol",
"test": "testSetAndGet",
"name": "Callbacks: set field",
"gasUsed": 56241
},
{
"file": "test/Callbacks.t.sol",
"test": "testSetAndGet",
"name": "Callbacks: get field (warm)",
"gasUsed": 2842
},
{
"file": "test/Callbacks.t.sol",
"test": "testSetAndGet",
"name": "Callbacks: push 1 element",
"gasUsed": 32499
},
{
"file": "test/FieldLayout.t.sol",
"test": "testEncodeDecodeFieldLayout",
Expand Down Expand Up @@ -960,137 +978,119 @@
"gasUsed": 108
},
{
"file": "test/StoreSwitch.t.sol",
"test": "testDelegatecall",
"name": "get Store address",
"gasUsed": 2170
},
{
"file": "test/StoreSwitch.t.sol",
"test": "testNoDelegatecall",
"name": "get Store address",
"gasUsed": 2173
},
{
"file": "test/tables/Callbacks.t.sol",
"test": "testSetAndGet",
"name": "Callbacks: set field",
"gasUsed": 56241
},
{
"file": "test/tables/Callbacks.t.sol",
"test": "testSetAndGet",
"name": "Callbacks: get field (warm)",
"gasUsed": 2842
},
{
"file": "test/tables/Callbacks.t.sol",
"test": "testSetAndGet",
"name": "Callbacks: push 1 element",
"gasUsed": 32499
},
{
"file": "test/tables/StoreHooks.t.sol",
"file": "test/StoreHooks.t.sol",
"test": "testOneSlot",
"name": "StoreHooks: set field with one elements (cold)",
"gasUsed": 58247
},
{
"file": "test/tables/StoreHooks.t.sol",
"file": "test/StoreHooks.t.sol",
"test": "testTable",
"name": "StoreHooks: set field (cold)",
"gasUsed": 58247
},
{
"file": "test/tables/StoreHooks.t.sol",
"file": "test/StoreHooks.t.sol",
"test": "testTable",
"name": "StoreHooks: get field (warm)",
"gasUsed": 2844
},
{
"file": "test/tables/StoreHooks.t.sol",
"file": "test/StoreHooks.t.sol",
"test": "testTable",
"name": "StoreHooks: push 1 element (cold)",
"gasUsed": 12597
},
{
"file": "test/tables/StoreHooks.t.sol",
"file": "test/StoreHooks.t.sol",
"test": "testTable",
"name": "StoreHooks: pop 1 element (warm)",
"gasUsed": 9931
},
{
"file": "test/tables/StoreHooks.t.sol",
"file": "test/StoreHooks.t.sol",
"test": "testTable",
"name": "StoreHooks: push 1 element (warm)",
"gasUsed": 10614
},
{
"file": "test/tables/StoreHooks.t.sol",
"file": "test/StoreHooks.t.sol",
"test": "testTable",
"name": "StoreHooks: update 1 element (warm)",
"gasUsed": 29840
},
{
"file": "test/tables/StoreHooks.t.sol",
"file": "test/StoreHooks.t.sol",
"test": "testTable",
"name": "StoreHooks: delete record (warm)",
"gasUsed": 10410
},
{
"file": "test/tables/StoreHooks.t.sol",
"file": "test/StoreHooks.t.sol",
"test": "testTable",
"name": "StoreHooks: set field (warm)",
"gasUsed": 30392
},
{
"file": "test/tables/StoreHooks.t.sol",
"file": "test/StoreHooks.t.sol",
"test": "testThreeSlots",
"name": "StoreHooks: set field with three elements (cold)",
"gasUsed": 80935
},
{
"file": "test/tables/StoreHooks.t.sol",
"file": "test/StoreHooks.t.sol",
"test": "testTwoSlots",
"name": "StoreHooks: set field with two elements (cold)",
"gasUsed": 80847
},
{
"file": "test/tables/StoreHooksColdLoad.t.sol",
"file": "test/StoreHooksColdLoad.t.sol",
"test": "testDelete",
"name": "StoreHooks: delete record (cold)",
"gasUsed": 19268
},
{
"file": "test/tables/StoreHooksColdLoad.t.sol",
"file": "test/StoreHooksColdLoad.t.sol",
"test": "testGet",
"name": "StoreHooks: get field (cold)",
"gasUsed": 8841
},
{
"file": "test/tables/StoreHooksColdLoad.t.sol",
"file": "test/StoreHooksColdLoad.t.sol",
"test": "testGetItem",
"name": "StoreHooks: get 1 element (cold)",
"gasUsed": 8486
},
{
"file": "test/tables/StoreHooksColdLoad.t.sol",
"file": "test/StoreHooksColdLoad.t.sol",
"test": "testLength",
"name": "StoreHooks: get length (cold)",
"gasUsed": 5394
},
{
"file": "test/tables/StoreHooksColdLoad.t.sol",
"file": "test/StoreHooksColdLoad.t.sol",
"test": "testPop",
"name": "StoreHooks: pop 1 element (cold)",
"gasUsed": 18366
},
{
"file": "test/tables/StoreHooksColdLoad.t.sol",
"file": "test/StoreHooksColdLoad.t.sol",
"test": "testUpdate",
"name": "StoreHooks: update 1 element (cold)",
"gasUsed": 20295
},
{
"file": "test/StoreSwitch.t.sol",
"test": "testDelegatecall",
"name": "get Store address",
"gasUsed": 2170
},
{
"file": "test/StoreSwitch.t.sol",
"test": "testNoDelegatecall",
"name": "get Store address",
"gasUsed": 2173
},
{
"file": "test/tightcoder/DecodeSlice.t.sol",
"test": "testToArrayUint32",
Expand Down
30 changes: 0 additions & 30 deletions packages/store/mud.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ import { mudConfig } from "./ts/register";
export default mudConfig({
storeImportPath: "../../",
namespace: "mudstore",
enums: {
ExampleEnum: ["None", "First", "Second", "Third"],
},
userTypes: {
ResourceId: { filePath: "./src/ResourceId.sol", internalType: "bytes32" },
FieldLayout: { filePath: "./src/FieldLayout.sol", internalType: "bytes32" },
Expand Down Expand Up @@ -50,32 +47,5 @@ export default mudConfig({
},
tableIdArgument: true,
},
// TODO: move these test tables to a separate mud config
Callbacks: "bytes24[]",
Mixed: {
valueSchema: {
u32: "uint32",
u128: "uint128",
a32: "uint32[]",
s: "string",
},
},
Vector2: {
valueSchema: {
x: "uint32",
y: "uint32",
},
},
KeyEncoding: {
keySchema: {
k1: "uint256",
k2: "int32",
k3: "bytes16",
k4: "address",
k5: "bool",
k6: "ExampleEnum",
},
valueSchema: "bool",
},
},
});
4 changes: 2 additions & 2 deletions packages/store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@
"build:abi": "forge build --skip test script",
"build:abi-ts": "abi-ts && prettier --write '**/*.abi.json.d.ts'",
"build:js": "tsup",
"build:mud": "tsx ./ts/scripts/tablegen.ts",
"build:mud": "tsx ./ts/scripts/tablegen.ts && tsx ./ts/scripts/generate-test-tables.ts",
"build:tightcoder": "tsx ./ts/scripts/generate-tightcoder.ts",
"clean": "pnpm run clean:abi && pnpm run clean:js && pnpm run clean:mud",
"clean:abi": "forge clean",
"clean:js": "rimraf dist",
"clean:mud": "rimraf src/codegen",
"clean:mud": "rimraf src/codegen && rimraf test/codegen",
"dev": "tsup --watch",
"gas-report": "gas-report --save gas-report.json",
"lint": "solhint --config ./.solhint.json 'src/**/*.sol'",
Expand Down
4 changes: 0 additions & 4 deletions packages/store/src/codegen/index.sol

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

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pragma solidity >=0.8.21;

import { Test } from "forge-std/Test.sol";
import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol";
import { StoreMock } from "../../test/StoreMock.sol";
import { Callbacks } from "../../src/codegen/index.sol";
import { Callbacks } from "./codegen/tables/Callbacks.sol";
import { StoreMock } from "./StoreMock.sol";

contract CallbacksTest is Test, GasReporter, StoreMock {
function testSetAndGet() public {
Expand Down
3 changes: 2 additions & 1 deletion packages/store/test/Gas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { Bytes } from "../src/Bytes.sol";
import { SliceLib } from "../src/Slice.sol";
import { Storage } from "../src/Storage.sol";
import { PackedCounter } from "../src/PackedCounter.sol";
import { Mixed, MixedData } from "../src/codegen/index.sol";

import { Mixed, MixedData } from "./codegen/index.sol";

contract SomeContract {
function doSomethingWithBytes(bytes memory data) public {}
Expand Down
7 changes: 4 additions & 3 deletions packages/store/test/KeyEncoding.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ pragma solidity >=0.8.21;

import { Test } from "forge-std/Test.sol";
import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol";
import { KeyEncoding, KeyEncodingTableId } from "../src/codegen/index.sol";
import { ExampleEnum } from "../src/codegen/common.sol";
import { StoreCore } from "../src/StoreCore.sol";
import { StoreMock } from "../test/StoreMock.sol";
import { FieldLayout } from "../src/FieldLayout.sol";
import { Schema } from "../src/Schema.sol";

import { StoreMock } from "./StoreMock.sol";
import { KeyEncoding, KeyEncodingTableId } from "./codegen/index.sol";
import { ExampleEnum } from "./codegen/common.sol";

contract KeyEncodingTest is Test, GasReporter, StoreMock {
function testRegisterAndGetFieldLayout() public {
startGasReport("register KeyEncoding table");
Expand Down
3 changes: 2 additions & 1 deletion packages/store/test/Mixed.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ pragma solidity >=0.8.21;

import { Test } from "forge-std/Test.sol";
import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol";
import { Mixed, MixedData, MixedTableId } from "../src/codegen/index.sol";
import { StoreCore } from "../src/StoreCore.sol";
import { StoreMock } from "../test/StoreMock.sol";
import { FieldLayout } from "../src/FieldLayout.sol";
import { Schema } from "../src/Schema.sol";
import { PackedCounter } from "../src/PackedCounter.sol";

import { Mixed, MixedData, MixedTableId } from "./codegen/index.sol";

contract MixedTest is Test, GasReporter, StoreMock {
MixedData private testMixed;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ pragma solidity >=0.8.21;

import { Test } from "forge-std/Test.sol";
import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol";
import { ResourceId } from "../../src/ResourceId.sol";
import { StoreHooks } from "../../src/codegen/index.sol";
import { StoreMock } from "../StoreMock.sol";
import { ResourceId } from "../src/ResourceId.sol";
import { StoreHooks } from "../src/codegen/tables/StoreHooks.sol";
import { StoreMock } from "./StoreMock.sol";

contract StoreHooksTest is Test, GasReporter, StoreMock {
function testTable() public {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ pragma solidity >=0.8.21;

import { Test } from "forge-std/Test.sol";
import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol";
import { ResourceId } from "../../src/ResourceId.sol";
import { StoreMock } from "../../test/StoreMock.sol";
import { StoreHooks } from "../../src/codegen/index.sol";
import { ResourceId } from "../src/ResourceId.sol";
import { StoreHooks } from "../src/codegen/tables/StoreHooks.sol";
import { StoreMock } from "./StoreMock.sol";

contract StoreHooksColdLoadTest is Test, GasReporter, StoreMock {
bytes21[] hooks;
Expand Down
3 changes: 2 additions & 1 deletion packages/store/test/Vector2.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ pragma solidity >=0.8.21;

import { Test } from "forge-std/Test.sol";
import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol";
import { Vector2, Vector2Data, Vector2TableId } from "../src/codegen/index.sol";
import { StoreCore } from "../src/StoreCore.sol";
import { StoreMock } from "../test/StoreMock.sol";
import { FieldLayout } from "../src/FieldLayout.sol";
import { Schema } from "../src/Schema.sol";

import { Vector2, Vector2Data, Vector2TableId } from "./codegen/index.sol";

contract Vector2Test is Test, GasReporter, StoreMock {
function testRegisterAndGetFieldLayout() public {
startGasReport("register Vector2 field layout");
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions packages/store/test/codegen/index.sol

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

Loading

0 comments on commit 90e4161

Please sign in to comment.