Skip to content

Commit

Permalink
test(store,world): update protocol version tests (#2493)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic authored Mar 21, 2024
1 parent 3e7d83d commit b0c45f8
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 14 deletions.
31 changes: 27 additions & 4 deletions packages/store/ts/protocol-snapshots/2.0.0.snap
Original file line number Diff line number Diff line change
@@ -1,16 +1,36 @@
[
"error EncodedLengths_InvalidLength(uint256 length)",
"error FieldLayout_Empty()",
"error FieldLayout_InvalidStaticDataLength(uint256 staticDataLength, uint256 computedStaticDataLength)",
"error FieldLayout_StaticLengthDoesNotFitInAWord(uint256 index)",
"error FieldLayout_StaticLengthIsNotZero(uint256 index)",
"error FieldLayout_StaticLengthIsZero(uint256 index)",
"error FieldLayout_TooManyDynamicFields(uint256 numFields, uint256 maxFields)",
"error FieldLayout_TooManyFields(uint256 numFields, uint256 maxFields)",
"error Schema_InvalidLength(uint256 length)",
"error Schema_StaticTypeAfterDynamicType()",
"error Slice_OutOfBounds(bytes data, uint256 start, uint256 end)",
"error Store_IndexOutOfBounds(uint256 length, uint256 accessedIndex)",
"error Store_InvalidBounds(uint256 start, uint256 end)",
"error Store_InvalidFieldNamesLength(uint256 expected, uint256 received)",
"error Store_InvalidKeyNamesLength(uint256 expected, uint256 received)",
"error Store_InvalidResourceType(bytes2 expected, bytes32 resourceId, string resourceIdString)",
"error Store_InvalidSplice(uint40 startWithinField, uint40 deleteCount, uint40 fieldLength)",
"error Store_InvalidStaticDataLength(uint256 expected, uint256 received)",
"error Store_InvalidValueSchemaDynamicLength(uint256 expected, uint256 received)",
"error Store_InvalidValueSchemaLength(uint256 expected, uint256 received)",
"error Store_InvalidValueSchemaStaticLength(uint256 expected, uint256 received)",
"error Store_TableAlreadyExists(bytes32 tableId, string tableIdString)",
"error Store_TableNotFound(bytes32 tableId, string tableIdString)",
"event HelloStore(bytes32 indexed storeVersion)",
"event Store_DeleteRecord(bytes32 indexed tableId, bytes32[] keyTuple)",
"event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)",
"event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint48 start, uint40 deleteCount, bytes32 encodedLengths, bytes data)",
"event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)",
"function deleteRecord(bytes32 tableId, bytes32[] keyTuple)",
"function getDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex) view returns (bytes data)",
"function getDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex) view returns (bytes)",
"function getDynamicFieldLength(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex) view returns (uint256)",
"function getDynamicFieldSlice(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint256 start, uint256 end) view returns (bytes)",
"function getDynamicFieldSlice(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint256 start, uint256 end) view returns (bytes data)",
"function getField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes32 fieldLayout) view returns (bytes data)",
"function getField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex) view returns (bytes data)",
"function getFieldLayout(bytes32 tableId) view returns (bytes32 fieldLayout)",
Expand All @@ -19,16 +39,19 @@
"function getKeySchema(bytes32 tableId) view returns (bytes32 keySchema)",
"function getRecord(bytes32 tableId, bytes32[] keyTuple, bytes32 fieldLayout) view returns (bytes staticData, bytes32 encodedLengths, bytes dynamicData)",
"function getRecord(bytes32 tableId, bytes32[] keyTuple) view returns (bytes staticData, bytes32 encodedLengths, bytes dynamicData)",
"function getStaticField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes32 fieldLayout) view returns (bytes32 data)",
"function getStaticField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes32 fieldLayout) view returns (bytes32)",
"function getValueSchema(bytes32 tableId) view returns (bytes32 valueSchema)",
"function popFromDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint256 byteLengthToPop)",
"function pushToDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, bytes dataToPush)",
"function registerStoreHook(bytes32 tableId, address hookAddress, uint8 enabledHooksBitmap)",
"function registerTable(bytes32 tableId, bytes32 fieldLayout, bytes32 keySchema, bytes32 valueSchema, string[] keyNames, string[] fieldNames)",
"function setDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, bytes data)",
"function setField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes data, bytes32 fieldLayout)",
"function setField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes data)",
"function setRecord(bytes32 tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)",
"function setStaticField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes data, bytes32 fieldLayout)",
"function spliceDynamicData(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint40 startWithinField, uint40 deleteCount, bytes data)",
"function spliceStaticData(bytes32 tableId, bytes32[] keyTuple, uint48 start, bytes data)",
"function storeVersion() pure returns (bytes32)",
"function storeVersion() view returns (bytes32 version)",
"function unregisterStoreHook(bytes32 tableId, address hookAddress)",
]
15 changes: 14 additions & 1 deletion packages/store/ts/protocolVersions.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
import { describe, expect, it } from "vitest";
import fs from "node:fs";
import StoreAbi from "../out/StoreData.sol/StoreData.abi.json";
import StoreAbi from "../out/IStore.sol/IStore.abi.json";
import { formatAbi } from "abitype";
import { protocolVersions } from "./protocolVersions";

/**
* If these tests fail, it's because the protocol changed since the last ABI + version snapshot.
*
* The fix for this depends on your needs:
*
* - If the change was an intentional iteration of the protocol, increment the `version.sol` file according to semver.
* A new protocol snapshot will be created when you run this test again, which you should check into git.
*
* - If the protocol change is for a yet-to-be-release version (i.e. the version was bumped but packages not yet published),
* or if _only_ parameter/return value names changed (which do not affect calldata), then it's safe to just
* update the protocol snapshot for this version (`vitest -u`).
*/

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

const currentAbi = formatAbi(StoreAbi).sort((a, b) => a.localeCompare(b));
Expand Down
51 changes: 43 additions & 8 deletions packages/world/ts/protocol-snapshots/2.0.0.snap
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
[
"constructor()",
"error EncodedLengths_InvalidLength(uint256 length)",
"error FieldLayout_Empty()",
"error FieldLayout_InvalidStaticDataLength(uint256 staticDataLength, uint256 computedStaticDataLength)",
"error FieldLayout_StaticLengthDoesNotFitInAWord(uint256 index)",
"error FieldLayout_StaticLengthIsNotZero(uint256 index)",
"error FieldLayout_StaticLengthIsZero(uint256 index)",
"error FieldLayout_TooManyDynamicFields(uint256 numFields, uint256 maxFields)",
"error FieldLayout_TooManyFields(uint256 numFields, uint256 maxFields)",
"error Module_AlreadyInstalled()",
"error Module_MissingDependency(address dependency)",
"error Module_NonRootInstallNotSupported()",
"error Module_RootInstallNotSupported()",
"error Schema_InvalidLength(uint256 length)",
"error Schema_StaticTypeAfterDynamicType()",
"error Slice_OutOfBounds(bytes data, uint256 start, uint256 end)",
"error Store_IndexOutOfBounds(uint256 length, uint256 accessedIndex)",
"error Store_InvalidBounds(uint256 start, uint256 end)",
"error Store_InvalidFieldNamesLength(uint256 expected, uint256 received)",
"error Store_InvalidKeyNamesLength(uint256 expected, uint256 received)",
"error Store_InvalidResourceType(bytes2 expected, bytes32 resourceId, string resourceIdString)",
"error Store_InvalidSplice(uint40 startWithinField, uint40 deleteCount, uint40 fieldLength)",
"error Store_InvalidStaticDataLength(uint256 expected, uint256 received)",
"error Store_InvalidValueSchemaDynamicLength(uint256 expected, uint256 received)",
"error Store_InvalidValueSchemaLength(uint256 expected, uint256 received)",
"error Store_InvalidValueSchemaStaticLength(uint256 expected, uint256 received)",
"error Store_TableAlreadyExists(bytes32 tableId, string tableIdString)",
"error Store_TableNotFound(bytes32 tableId, string tableIdString)",
"error World_AccessDenied(string resource, address caller)",
"error World_AlreadyInitialized()",
Expand All @@ -32,14 +47,15 @@
"event Store_SetRecord(bytes32 indexed tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)",
"event Store_SpliceDynamicData(bytes32 indexed tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint48 start, uint40 deleteCount, bytes32 encodedLengths, bytes data)",
"event Store_SpliceStaticData(bytes32 indexed tableId, bytes32[] keyTuple, uint48 start, bytes data)",
"fallback()",
"function batchCall((bytes32 systemId, bytes callData)[] systemCalls) returns (bytes[] returnDatas)",
"function batchCallFrom((address from, bytes32 systemId, bytes callData)[] systemCalls) returns (bytes[] returnDatas)",
"function call(bytes32 systemId, bytes callData) payable returns (bytes)",
"function callFrom(address delegator, bytes32 systemId, bytes callData) payable returns (bytes)",
"function creator() view returns (address)",
"function deleteRecord(bytes32 tableId, bytes32[] keyTuple)",
"function getDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex) view returns (bytes data)",
"function getDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex) view returns (bytes)",
"function getDynamicFieldLength(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex) view returns (uint256)",
"function getDynamicFieldSlice(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint256 start, uint256 end) view returns (bytes)",
"function getDynamicFieldSlice(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint256 start, uint256 end) view returns (bytes data)",
"function getField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes32 fieldLayout) view returns (bytes data)",
"function getField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex) view returns (bytes data)",
"function getFieldLayout(bytes32 tableId) view returns (bytes32 fieldLayout)",
Expand All @@ -48,20 +64,39 @@
"function getKeySchema(bytes32 tableId) view returns (bytes32 keySchema)",
"function getRecord(bytes32 tableId, bytes32[] keyTuple, bytes32 fieldLayout) view returns (bytes staticData, bytes32 encodedLengths, bytes dynamicData)",
"function getRecord(bytes32 tableId, bytes32[] keyTuple) view returns (bytes staticData, bytes32 encodedLengths, bytes dynamicData)",
"function getStaticField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes32 fieldLayout) view returns (bytes32 data)",
"function getStaticField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes32 fieldLayout) view returns (bytes32)",
"function getValueSchema(bytes32 tableId) view returns (bytes32 valueSchema)",
"function grantAccess(bytes32 resourceId, address grantee)",
"function initialize(address initModule)",
"function installModule(address module, bytes encodedArgs)",
"function installRootModule(address module, bytes encodedArgs)",
"function popFromDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint256 byteLengthToPop)",
"function pushToDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, bytes dataToPush)",
"function registerDelegation(address delegatee, bytes32 delegationControlId, bytes initCallData)",
"function registerFunctionSelector(bytes32 systemId, string systemFunctionSignature) returns (bytes4 worldFunctionSelector)",
"function registerNamespace(bytes32 namespaceId)",
"function registerNamespaceDelegation(bytes32 namespaceId, bytes32 delegationControlId, bytes initCallData)",
"function registerRootFunctionSelector(bytes32 systemId, string worldFunctionSignature, string systemFunctionSignature) returns (bytes4 worldFunctionSelector)",
"function registerStoreHook(bytes32 tableId, address hookAddress, uint8 enabledHooksBitmap)",
"function registerSystem(bytes32 systemId, address system, bool publicAccess)",
"function registerSystemHook(bytes32 systemId, address hookAddress, uint8 enabledHooksBitmap)",
"function registerTable(bytes32 tableId, bytes32 fieldLayout, bytes32 keySchema, bytes32 valueSchema, string[] keyNames, string[] fieldNames)",
"function renounceOwnership(bytes32 namespaceId)",
"function revokeAccess(bytes32 resourceId, address grantee)",
"function setDynamicField(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, bytes data)",
"function setField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes data, bytes32 fieldLayout)",
"function setField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes data)",
"function setRecord(bytes32 tableId, bytes32[] keyTuple, bytes staticData, bytes32 encodedLengths, bytes dynamicData)",
"function setStaticField(bytes32 tableId, bytes32[] keyTuple, uint8 fieldIndex, bytes data, bytes32 fieldLayout)",
"function spliceDynamicData(bytes32 tableId, bytes32[] keyTuple, uint8 dynamicFieldIndex, uint40 startWithinField, uint40 deleteCount, bytes data)",
"function spliceStaticData(bytes32 tableId, bytes32[] keyTuple, uint48 start, bytes data)",
"function storeVersion() pure returns (bytes32)",
"function worldVersion() pure returns (bytes32)",
"receive() external payable",
"function storeVersion() view returns (bytes32 version)",
"function transferBalanceToAddress(bytes32 fromNamespaceId, address toAddress, uint256 amount)",
"function transferBalanceToNamespace(bytes32 fromNamespaceId, bytes32 toNamespaceId, uint256 amount)",
"function transferOwnership(bytes32 namespaceId, address newOwner)",
"function unregisterDelegation(address delegatee)",
"function unregisterNamespaceDelegation(bytes32 namespaceId)",
"function unregisterStoreHook(bytes32 tableId, address hookAddress)",
"function unregisterSystemHook(bytes32 systemId, address hookAddress)",
"function worldVersion() view returns (bytes32)",
]
15 changes: 14 additions & 1 deletion packages/world/ts/protocolVersions.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
import { describe, expect, it } from "vitest";
import fs from "node:fs";
import WorldAbi from "../out/World.sol/World.abi.json";
import WorldAbi from "../out/IBaseWorld.sol/IBaseWorld.abi.json";
import { formatAbi } from "abitype";
import { protocolVersions } from "./protocolVersions";

/**
* If these tests fail, it's because the protocol changed since the last ABI + version snapshot.
*
* The fix for this depends on your needs:
*
* - If the change was an intentional iteration of the protocol, increment the `version.sol` file according to semver.
* A new protocol snapshot will be created when you run this test again, which you should check into git.
*
* - If the protocol change is for a yet-to-be-release version (i.e. the version was bumped but packages not yet published),
* or if _only_ parameter/return value names changed (which do not affect calldata), then it's safe to just
* update the protocol snapshot for this version (`vitest -u`).
*/

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

const currentAbi = formatAbi(WorldAbi).sort((a, b) => a.localeCompare(b));
Expand Down

0 comments on commit b0c45f8

Please sign in to comment.