Skip to content

Commit

Permalink
test: extra scenario test, minor renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Zer0dot committed Jul 11, 2024
1 parent 1d45b2e commit 883eff5
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions test/account/DirectCallsFromPlugin.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,42 @@ contract DirectCallsFromPluginTest is AccountTestBase {
account1.executeBatch(calls);
}

function test_Pass_DirectCallFromPlugin_MockFlow() external {
function test_Pass_DirectCallFromPluginPrank() external {
_installPlugin();

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

function test_Pass_DirectCallFromPlugin_NormalFlow() external {
function test_Pass_DirectCallFromPluginCallback() external {
_installPlugin();

bytes memory encodedCall = abi.encodeCall(DirectCallPlugin.directCall, ());

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

// 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));
account1.execute(address(0), 0, "");

vm.prank(address(entryPoint));
account1.uninstallPlugin(address(plugin), "", "");

vm.prank(address(plugin));
vm.expectRevert(_buildDirectCallDisallowedError(IStandardExecutor.execute.selector));
account1.execute(address(0), 0, "");
}

/* -------------------------------------------------------------------------- */
/* Internals */
/* -------------------------------------------------------------------------- */
Expand Down

0 comments on commit 883eff5

Please sign in to comment.