Skip to content

Commit

Permalink
performance: use built in mock erc20 instead of custom dummy erc20
Browse files Browse the repository at this point in the history
  • Loading branch information
gosuto-inzasheru committed Mar 10, 2024
1 parent edd73d2 commit a0f219d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 33 deletions.
10 changes: 0 additions & 10 deletions src/DummyERC20.sol

This file was deleted.

37 changes: 14 additions & 23 deletions test/Revoooker.t.sol
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;
pragma solidity ^0.8.24;

import "forge-std/console.sol";
import { Test } from "forge-std/Test.sol";
import {
RhinestoneModuleKit,
ModuleKitHelpers,
ModuleKitUserOp,
AccountInstance
} from "modulekit/ModuleKit.sol";
import "forge-std/Test.sol";
import "modulekit/ModuleKit.sol";
import "modulekit/Mocks.sol";
import { MODULE_TYPE_EXECUTOR } from "modulekit/external/ERC7579.sol";
import { ExecutionLib } from "erc7579/lib/ExecutionLib.sol";
import { IERC20 } from "forge-std/interfaces/IERC20.sol";
import { Revoooker } from "src/Revoooker.sol";
import { DummyERC20 } from "src/DummyERC20.sol";

contract RevoookerTest is RhinestoneModuleKit, Test {
using ModuleKitHelpers for *;
using ModuleKitUserOp for *;

uint256 mainnetFork;

// account and modules
AccountInstance internal instance;
Revoooker internal revoker;
DummyERC20 internal dummy;
MockERC20 internal mock;

function setUp() public {
// Initialize the RhinestoneModuleKit
Expand All @@ -34,9 +25,9 @@ contract RevoookerTest is RhinestoneModuleKit, Test {
revoker = new Revoooker();
vm.label(address(revoker), "Revoooker");

// Deploy a dummy erc20
dummy = new DummyERC20();
vm.label(address(dummy), "DummyERC20");
// Deploy a mock erc20
mock = new MockERC20();
vm.label(address(mock), "MockERC20");

// Create the account and install the revoker
instance = makeAccountInstance("Revoooker");
Expand All @@ -54,18 +45,18 @@ contract RevoookerTest is RhinestoneModuleKit, Test {
// Confirm the revoker is installed
assert(instance.isModuleInstalled(MODULE_TYPE_EXECUTOR, address(revoker), ""));

// Set up an allowance for spender on the dummy erc20
// Set up an allowance for spender on the mock erc20
address spender = makeAddr("spender");
assertEq(dummy.allowance(instance.account, spender), 0);
dummy.approve(spender, 1 ether);
assertGt(dummy.allowance(instance.account, spender), 0);
assertEq(mock.allowance(instance.account, spender), 0);
mock.approve(spender, 1 ether);
assertGt(mock.allowance(instance.account, spender), 0);

// Get rid of the allowance using the revoooker
instance.exec({
target: address(revoker),
value: 0,
callData: abi.encodeCall(Revoooker.revoke, (address(dummy), spender))
callData: abi.encodeCall(Revoooker.revoke, (address(mock), spender))
});
assertEq(dummy.allowance(instance.account, spender), 0);
assertEq(mock.allowance(instance.account, spender), 0);
}
}

0 comments on commit a0f219d

Please sign in to comment.