Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alvrs committed Sep 17, 2023
1 parent 2c1e155 commit 7920196
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 73 deletions.
2 changes: 1 addition & 1 deletion packages/store/src/StoreCore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ library StoreCoreInternal {
// Store the provided value in storage
{
uint256 dynamicDataLocation = _getDynamicDataLocation(tableId, keyTuple, dynamicFieldIndex);
Storage.store({ storagePointer: dynamicDataLocation, offset: start, data: data });
Storage.store({ storagePointer: dynamicDataLocation, offset: startWithinField, data: data });
}

// Call onAfterSpliceDynamicData hooks
Expand Down
42 changes: 26 additions & 16 deletions packages/store/test/EchoSubscriber.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ contract EchoSubscriber is StoreHook {
bytes memory dynamicData,
FieldLayout fieldLayout
) public {
emit HookCalled(abi.encode(tableId, keyTuple, staticData, encodedLengths, dynamicData, fieldLayout));
emit HookCalled(
abi.encodeCall(this.onBeforeSetRecord, (tableId, keyTuple, staticData, encodedLengths, dynamicData, fieldLayout))
);
}

function onAfterSetRecord(
Expand All @@ -27,62 +29,70 @@ contract EchoSubscriber is StoreHook {
bytes memory dynamicData,
FieldLayout fieldLayout
) public {
emit HookCalled(abi.encode(tableId, keyTuple, staticData, encodedLengths, dynamicData, fieldLayout));
emit HookCalled(
abi.encodeCall(this.onAfterSetRecord, (tableId, keyTuple, staticData, encodedLengths, dynamicData, fieldLayout))
);
}

function onBeforeSpliceStaticData(
bytes32 tableId,
bytes32[] calldata keyTuple,
bytes32[] memory keyTuple,
uint48 start,
uint40 deleteCount,
bytes calldata data
bytes memory data
) public {
emit HookCalled(abi.encode(tableId, keyTuple, start, deleteCount, data));
emit HookCalled(abi.encodeCall(this.onBeforeSpliceStaticData, (tableId, keyTuple, start, deleteCount, data)));
}

function onAfterSpliceStaticData(
bytes32 tableId,
bytes32[] calldata keyTuple,
bytes32[] memory keyTuple,
uint48 start,
uint40 deleteCount,
bytes calldata data
bytes memory data
) public {
emit HookCalled(abi.encode(tableId, keyTuple, start, deleteCount, data));
emit HookCalled(abi.encodeCall(this.onAfterSpliceStaticData, (tableId, keyTuple, start, deleteCount, data)));
}

function onBeforeSpliceDynamicData(
bytes32 tableId,
bytes32[] calldata keyTuple,
bytes32[] memory keyTuple,
uint8 dynamicFieldIndex,
uint40 startWithinField,
uint40 deleteCount,
bytes calldata data,
bytes memory data,
PackedCounter encodedLengths
) public {
emit HookCalled(
abi.encode(tableId, keyTuple, dynamicFieldIndex, startWithinField, deleteCount, data, encodedLengths.unwrap())
abi.encodeCall(
this.onBeforeSpliceDynamicData,
(tableId, keyTuple, dynamicFieldIndex, startWithinField, deleteCount, data, encodedLengths)
)
);
}

function onAfterSpliceDynamicData(
bytes32 tableId,
bytes32[] calldata keyTuple,
bytes32[] memory keyTuple,
uint8 dynamicFieldIndex,
uint40 startWithinField,
uint40 deleteCount,
bytes calldata data,
bytes memory data,
PackedCounter encodedLengths
) public {
emit HookCalled(
abi.encode(tableId, keyTuple, dynamicFieldIndex, startWithinField, deleteCount, data, encodedLengths.unwrap())
abi.encodeCall(
this.onAfterSpliceDynamicData,
(tableId, keyTuple, dynamicFieldIndex, startWithinField, deleteCount, data, encodedLengths)
)
);
}

function onBeforeDeleteRecord(bytes32 tableId, bytes32[] memory keyTuple, FieldLayout fieldLayout) public {
emit HookCalled(abi.encode(tableId, keyTuple, fieldLayout));
emit HookCalled(abi.encodeCall(this.onBeforeDeleteRecord, (tableId, keyTuple, fieldLayout)));
}

function onAfterDeleteRecord(bytes32 tableId, bytes32[] memory keyTuple, FieldLayout fieldLayout) public {
emit HookCalled(abi.encode(tableId, keyTuple, fieldLayout));
emit HookCalled(abi.encodeCall(this.onAfterDeleteRecord, (tableId, keyTuple, fieldLayout)));
}
}
Loading

0 comments on commit 7920196

Please sign in to comment.