mirror of
https://github.com/lens-protocol/core.git
synced 2026-04-22 03:02:03 -04:00
misc: MockActionModule includes a flag for initialization success too
This commit is contained in:
@@ -185,6 +185,9 @@ contract TestSetup is Test, ForkManagement, ArrayHelpers {
|
||||
}
|
||||
|
||||
function setUp() public virtual {
|
||||
vm.label(address(hub), 'LensHub');
|
||||
vm.label(address(governance), 'Governance');
|
||||
|
||||
// Compute the domain separator.
|
||||
domainSeparator = keccak256(
|
||||
abi.encode(
|
||||
@@ -210,7 +213,7 @@ contract TestSetup is Test, ForkManagement, ArrayHelpers {
|
||||
profileId: newProfileId,
|
||||
contentURI: MOCK_URI,
|
||||
actionModules: _toAddressArray(address(mockActionModule)),
|
||||
actionModulesInitDatas: _toBytesArray(abi.encode(1)),
|
||||
actionModulesInitDatas: _toBytesArray(abi.encode(true)),
|
||||
referenceModule: address(0),
|
||||
referenceModuleInitData: ''
|
||||
});
|
||||
|
||||
@@ -15,23 +15,29 @@ contract MockActionModule is IPublicationActionModule {
|
||||
// Prevents being counted in Foundry Coverage
|
||||
}
|
||||
|
||||
// Reverts if `data` does not decode as `true`.
|
||||
function initializePublicationAction(
|
||||
uint256 /** profileId*/,
|
||||
uint256 /** pubId*/,
|
||||
address /** transactionExecutor*/,
|
||||
bytes calldata data
|
||||
) external pure override returns (bytes memory) {
|
||||
return data;
|
||||
return _decodeFlagAndRevertIfFalse(data);
|
||||
}
|
||||
|
||||
// In the actionModuleData: Pass "True" for success, "False" for revert
|
||||
// Reverts if `processActionParams.actionModuleData` does not decode as `true`.
|
||||
function processPublicationAction(
|
||||
Types.ProcessActionParams calldata processActionParams
|
||||
) external pure override returns (bytes memory) {
|
||||
bool shouldItSucceed = abi.decode(processActionParams.actionModuleData, (bool));
|
||||
return _decodeFlagAndRevertIfFalse(processActionParams.actionModuleData);
|
||||
}
|
||||
|
||||
// Reverts if the flag decoded from the data is not `true`.
|
||||
function _decodeFlagAndRevertIfFalse(bytes memory data) internal pure returns (bytes memory) {
|
||||
bool shouldItSucceed = abi.decode(data, (bool));
|
||||
if (!shouldItSucceed) {
|
||||
revert MockActionModuleReverted();
|
||||
}
|
||||
return processActionParams.actionModuleData;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user