Skip to content

Commit

Permalink
chore: linting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zer0dot committed Jul 16, 2024
1 parent 4aa008c commit ae26e5f
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions test/account/DirectCallsFromPlugin.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ import {AccountTestBase} from "../utils/AccountTestBase.sol";
contract DirectCallsFromPluginTest is AccountTestBase {
using ValidationConfigLib for ValidationConfig;

DirectCallPlugin internal plugin;
FunctionReference internal pluginFunctionReference;
DirectCallPlugin internal _plugin;
FunctionReference internal _pluginFunctionReference;

function setUp() public {
plugin = new DirectCallPlugin();
assertFalse(plugin.preHookRan());
assertFalse(plugin.postHookRan());
pluginFunctionReference = FunctionReferenceLib.pack(address(plugin), type(uint8).max);
_plugin = new DirectCallPlugin();
assertFalse(_plugin.preHookRan());
assertFalse(_plugin.postHookRan());
_pluginFunctionReference = FunctionReferenceLib.pack(address(_plugin), type(uint8).max);
}

/* -------------------------------------------------------------------------- */
/* Negatives */
/* -------------------------------------------------------------------------- */

function test_Fail_DirectCallPluginNotInstalled() external {
vm.prank(address(plugin));
vm.prank(address(_plugin));
vm.expectRevert(_buildDirectCallDisallowedError(IStandardExecutor.execute.selector));
account1.execute(address(0), 0, "");
}
Expand All @@ -37,7 +37,7 @@ contract DirectCallsFromPluginTest is AccountTestBase {

_uninstallPlugin();

vm.prank(address(plugin));
vm.prank(address(_plugin));
vm.expectRevert(_buildDirectCallDisallowedError(IStandardExecutor.execute.selector));
account1.execute(address(0), 0, "");
}
Expand All @@ -47,7 +47,7 @@ contract DirectCallsFromPluginTest is AccountTestBase {

Call[] memory calls = new Call[](0);

vm.prank(address(plugin));
vm.prank(address(_plugin));
vm.expectRevert(_buildDirectCallDisallowedError(IStandardExecutor.executeBatch.selector));
account1.executeBatch(calls);
}
Expand All @@ -59,11 +59,11 @@ contract DirectCallsFromPluginTest is AccountTestBase {
function test_Pass_DirectCallFromPluginPrank() external {
_installPlugin();

vm.prank(address(plugin));
vm.prank(address(_plugin));
account1.execute(address(0), 0, "");

assertTrue(plugin.preHookRan());
assertTrue(plugin.postHookRan());
assertTrue(_plugin.preHookRan());
assertTrue(_plugin.postHookRan());
}

function test_Pass_DirectCallFromPluginCallback() external {
Expand All @@ -72,30 +72,30 @@ contract DirectCallsFromPluginTest is AccountTestBase {
bytes memory encodedCall = abi.encodeCall(DirectCallPlugin.directCall, ());

vm.prank(address(entryPoint));
bytes memory result = account1.execute(address(plugin), 0, encodedCall);
bytes memory result = account1.execute(address(_plugin), 0, encodedCall);

assertTrue(plugin.preHookRan());
assertTrue(plugin.postHookRan());
assertTrue(_plugin.preHookRan());
assertTrue(_plugin.postHookRan());

// the directCall() function in the plugin calls back into `execute()` with an encoded call back into the
// plugin's getData() function.
assertEq(abi.decode(result, (bytes)), abi.encode(plugin.getData()));
// the directCall() function in the _plugin calls back into `execute()` with an encoded call back into the
// _plugin's getData() function.
assertEq(abi.decode(result, (bytes)), abi.encode(_plugin.getData()));
}

function test_Flow_DirectCallFromPluginSequence() external {
// Install => Succeesfully call => uninstall => fail to call

_installPlugin();

vm.prank(address(plugin));
vm.prank(address(_plugin));
account1.execute(address(0), 0, "");

assertTrue(plugin.preHookRan());
assertTrue(plugin.postHookRan());
assertTrue(_plugin.preHookRan());
assertTrue(_plugin.postHookRan());

_uninstallPlugin();

vm.prank(address(plugin));
vm.prank(address(_plugin));
vm.expectRevert(_buildDirectCallDisallowedError(IStandardExecutor.execute.selector));
account1.execute(address(0), 0, "");
}
Expand All @@ -112,7 +112,7 @@ contract DirectCallsFromPluginTest is AccountTestBase {
bytes[] memory permissionHookInitDatas = new bytes[](1);

permissionHooks[0] = ExecutionHook({
hookFunction: FunctionReferenceLib.pack(address(plugin), 0xff),
hookFunction: FunctionReferenceLib.pack(address(_plugin), 0xff),
isPreHook: true,
isPostHook: true
});
Expand All @@ -121,21 +121,21 @@ contract DirectCallsFromPluginTest is AccountTestBase {

vm.prank(address(entryPoint));

ValidationConfig validationConfig = ValidationConfigLib.pack(pluginFunctionReference, false, false);
ValidationConfig validationConfig = ValidationConfigLib.pack(_pluginFunctionReference, false, false);

account1.installValidation(validationConfig, selectors, "", "", encodedPermissionHooks);
}

function _uninstallPlugin() internal {
vm.prank(address(entryPoint));
account1.uninstallValidation(
pluginFunctionReference, "", abi.encode(new bytes[](0)), abi.encode(new bytes[](1))
_pluginFunctionReference, "", abi.encode(new bytes[](0)), abi.encode(new bytes[](1))
);
}

function _buildDirectCallDisallowedError(bytes4 selector) internal view returns (bytes memory) {
return abi.encodeWithSelector(
UpgradeableModularAccount.ExecFromPluginNotPermitted.selector, address(plugin), selector
UpgradeableModularAccount.ExecFromPluginNotPermitted.selector, address(_plugin), selector
);
}
}

0 comments on commit ae26e5f

Please sign in to comment.