Skip to content

Commit

Permalink
test: remove mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
MathisGD committed May 13, 2024
1 parent 7bec750 commit ccac0bf
Show file tree
Hide file tree
Showing 26 changed files with 35 additions and 176 deletions.
6 changes: 0 additions & 6 deletions src/mocks/bundlers/BaseBundlerMock.sol

This file was deleted.

7 changes: 0 additions & 7 deletions src/mocks/bundlers/ERC20WrapperBundlerMock.sol

This file was deleted.

7 changes: 0 additions & 7 deletions src/mocks/bundlers/ERC4626BundlerMock.sol

This file was deleted.

13 changes: 0 additions & 13 deletions src/mocks/bundlers/MorphoBundlerMock.sol

This file was deleted.

6 changes: 0 additions & 6 deletions src/mocks/bundlers/Permit2BundlerMock.sol

This file was deleted.

7 changes: 0 additions & 7 deletions src/mocks/bundlers/PermitBundlerMock.sol

This file was deleted.

6 changes: 0 additions & 6 deletions src/mocks/bundlers/TransferBundlerMock.sol

This file was deleted.

6 changes: 0 additions & 6 deletions src/mocks/bundlers/UrdBundlerMock.sol

This file was deleted.

9 changes: 0 additions & 9 deletions src/mocks/bundlers/WNativeBundlerMock.sol

This file was deleted.

6 changes: 0 additions & 6 deletions src/mocks/bundlers/ethereum/EthereumPermitBundlerMock.sol

This file was deleted.

8 changes: 0 additions & 8 deletions src/mocks/bundlers/ethereum/EthereumStEthBundlerMock.sol

This file was deleted.

2 changes: 1 addition & 1 deletion test/forge/BaseBundlerEnshrinedLocalTest.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;

import {BaseBundler} from "src/mocks/bundlers/BaseBundlerMock.sol";
import {BaseBundler} from "src/BaseBundler.sol";

import "./helpers/LocalTest.sol";

Expand Down
8 changes: 0 additions & 8 deletions test/forge/BaseBundlerLocalTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@ pragma solidity ^0.8.0;

import {ErrorsLib} from "src/libraries/ErrorsLib.sol";

import "src/mocks/bundlers/BaseBundlerMock.sol";

import "./helpers/LocalTest.sol";

contract BaseBundlerLocalTest is LocalTest {
function setUp() public override {
super.setUp();

bundler = new BaseBundlerMock();
}

function testMulticallEmpty() public {
bundler.multicall(bundle);
}
Expand Down
3 changes: 0 additions & 3 deletions test/forge/ERC20WrapperBundlerLocalTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pragma solidity ^0.8.0;

import {ErrorsLib} from "../../src/libraries/ErrorsLib.sol";

import {ERC20WrapperBundlerMock} from "../../src/mocks/bundlers/ERC20WrapperBundlerMock.sol";
import {ERC20WrapperMock, ERC20Wrapper} from "../../src/mocks/ERC20WrapperMock.sol";

import "./helpers/LocalTest.sol";
Expand All @@ -14,8 +13,6 @@ contract ERC20WrapperBundlerBundlerLocalTest is LocalTest {
function setUp() public override {
super.setUp();

bundler = new ERC20WrapperBundlerMock();

loanWrapper = new ERC20WrapperMock(loanToken, "Wrapped Loan Token", "WLT");
}

Expand Down
11 changes: 4 additions & 7 deletions test/forge/ERC4626BundlerLocalTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pragma solidity ^0.8.0;
import {ErrorsLib} from "../../src/libraries/ErrorsLib.sol";

import {ERC4626Mock} from "../../src/mocks/ERC4626Mock.sol";
import "../../src/mocks/bundlers/ERC4626BundlerMock.sol";

import "./helpers/LocalTest.sol";

Expand All @@ -14,8 +13,6 @@ contract ERC4626BundlerLocalTest is LocalTest {
function setUp() public override {
super.setUp();

bundler = new ERC4626BundlerMock();

vault = new ERC4626Mock(address(loanToken), "LoanToken Vault", "BV");

vm.startPrank(USER);
Expand All @@ -27,7 +24,7 @@ contract ERC4626BundlerLocalTest is LocalTest {

function test4626MintUninitiated(uint256 shares) public {
vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
ERC4626BundlerMock(address(bundler)).erc4626Mint(address(vault), 0, shares, RECEIVER);
ERC4626Bundler(address(bundler)).erc4626Mint(address(vault), 0, shares, RECEIVER);
}

function testErc4626MintZeroAdressVault(uint256 shares) public {
Expand All @@ -46,7 +43,7 @@ contract ERC4626BundlerLocalTest is LocalTest {

function test4626DepositUninitiated(uint256 assets) public {
vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
ERC4626BundlerMock(address(bundler)).erc4626Deposit(address(vault), assets, 0, RECEIVER);
ERC4626Bundler(address(bundler)).erc4626Deposit(address(vault), assets, 0, RECEIVER);
}

function testErc4626DepositZeroAdressVault(uint256 assets) public {
Expand All @@ -65,7 +62,7 @@ contract ERC4626BundlerLocalTest is LocalTest {

function test4626WithdrawUninitiated(uint256 assets) public {
vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
ERC4626BundlerMock(address(bundler)).erc4626Withdraw(address(vault), assets, 0, RECEIVER, address(bundler));
ERC4626Bundler(address(bundler)).erc4626Withdraw(address(vault), assets, 0, RECEIVER, address(bundler));
}

function testErc4626WithdrawZeroAdressVault(uint256 assets) public {
Expand Down Expand Up @@ -93,7 +90,7 @@ contract ERC4626BundlerLocalTest is LocalTest {

function test4626RedeemUninitiated(uint256 shares) public {
vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
ERC4626BundlerMock(address(bundler)).erc4626Redeem(address(vault), shares, 0, RECEIVER, address(bundler));
ERC4626Bundler(address(bundler)).erc4626Redeem(address(vault), shares, 0, RECEIVER, address(bundler));
}

function testErc4626RedeemZeroAdressVault(uint256 shares) public {
Expand Down
10 changes: 3 additions & 7 deletions test/forge/MorphoBundlerLocalTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import {ErrorsLib} from "../../src/libraries/ErrorsLib.sol";
import {ErrorsLib as MorphoErrorsLib} from "../../lib/morpho-blue/src/libraries/ErrorsLib.sol";
import {MarketParamsLib} from "../../lib/morpho-blue/src/libraries/MarketParamsLib.sol";

import "../../src/mocks/bundlers/MorphoBundlerMock.sol";

import "./helpers/MetaMorphoLocalTest.sol";

contract MorphoBundlerLocalTest is MetaMorphoLocalTest {
Expand All @@ -27,8 +25,6 @@ contract MorphoBundlerLocalTest is MetaMorphoLocalTest {
function setUp() public override {
super.setUp();

bundler = new MorphoBundlerMock(address(morpho));

vm.startPrank(USER);
loanToken.approve(address(morpho), type(uint256).max);
collateralToken.approve(address(morpho), type(uint256).max);
Expand Down Expand Up @@ -226,7 +222,7 @@ contract MorphoBundlerLocalTest is MetaMorphoLocalTest {

function testWithdrawUninitiated(uint256 withdrawnShares) public {
vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
MorphoBundlerMock(address(bundler)).morphoWithdraw(marketParams, 0, withdrawnShares, 0, RECEIVER);
MorphoBundler(address(bundler)).morphoWithdraw(marketParams, 0, withdrawnShares, 0, RECEIVER);
}

function testWithdraw(uint256 privateKey, uint256 amount, uint256 withdrawnShares) public {
Expand Down Expand Up @@ -263,7 +259,7 @@ contract MorphoBundlerLocalTest is MetaMorphoLocalTest {

function testBorrowUnititiated(uint256 borrowedAssets) public {
vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
MorphoBundlerMock(address(bundler)).morphoBorrow(marketParams, borrowedAssets, 0, type(uint256).max, RECEIVER);
MorphoBundler(address(bundler)).morphoBorrow(marketParams, borrowedAssets, 0, type(uint256).max, RECEIVER);
}

function _testSupplyCollateralBorrow(address user, uint256 amount, uint256 collateralAmount) internal {
Expand Down Expand Up @@ -337,7 +333,7 @@ contract MorphoBundlerLocalTest is MetaMorphoLocalTest {

function testWithdrawCollateralUninitiated(uint256 collateralAmount) public {
vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
MorphoBundlerMock(address(bundler)).morphoWithdrawCollateral(marketParams, collateralAmount, RECEIVER);
MorphoBundler(address(bundler)).morphoWithdrawCollateral(marketParams, collateralAmount, RECEIVER);
}

function _testRepayWithdrawCollateral(address user, uint256 collateralAmount) internal {
Expand Down
7 changes: 3 additions & 4 deletions test/forge/PermitBundlerLocalTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ pragma solidity ^0.8.0;

import {SigUtils, Permit} from "./helpers/SigUtils.sol";

import "../../src/mocks/bundlers/PermitBundlerMock.sol";
import {ErrorsLib} from "src/libraries/ErrorsLib.sol";
import {IERC20Permit} from "openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Permit.sol";
import {ERC20PermitMock} from "../../src/mocks/ERC20PermitMock.sol";

import "./helpers/LocalTest.sol";
Expand All @@ -14,8 +15,6 @@ contract PermitBundlerLocalTest is LocalTest {
function setUp() public override {
super.setUp();

bundler = new PermitBundlerMock();

permitToken = new ERC20PermitMock("Permit Token", "PT");
}

Expand All @@ -39,7 +38,7 @@ contract PermitBundlerLocalTest is LocalTest {
amount = bound(amount, MIN_AMOUNT, MAX_AMOUNT);

vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
PermitBundlerMock(address(bundler)).permit(address(loanToken), amount, SIGNATURE_DEADLINE, 0, 0, 0, true);
PermitBundler(address(bundler)).permit(address(loanToken), amount, SIGNATURE_DEADLINE, 0, 0, 0, true);
}

function testPermitRevert(uint256 amount, uint256 privateKey, uint256 deadline) public {
Expand Down
10 changes: 1 addition & 9 deletions test/forge/TransferBundlerLocalTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@ pragma solidity ^0.8.0;

import {ErrorsLib} from "../../src/libraries/ErrorsLib.sol";

import "../../src/mocks/bundlers/TransferBundlerMock.sol";

import "./helpers/LocalTest.sol";

contract TransferBundlerLocalTest is LocalTest {
function setUp() public override {
super.setUp();

bundler = new TransferBundlerMock();
}

function testTransfer(uint256 amount) public {
amount = bound(amount, 0, MAX_AMOUNT);

Expand Down Expand Up @@ -96,7 +88,7 @@ contract TransferBundlerLocalTest is LocalTest {
amount = bound(amount, MIN_AMOUNT, MAX_AMOUNT);

vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
TransferBundlerMock(address(bundler)).erc20TransferFrom(address(loanToken), amount);
TransferBundler(address(bundler)).erc20TransferFrom(address(loanToken), amount);
}

function testTranferFromZeroAddress(uint256 amount) public {
Expand Down
3 changes: 0 additions & 3 deletions test/forge/UrdBundlerLocalTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {ErrorsLib as UrdErrorsLib} from "../../lib/universal-rewards-distributor

import {Merkle} from "../../lib/murky/src/Merkle.sol";

import "../../src/mocks/bundlers/UrdBundlerMock.sol";

import "./helpers/LocalTest.sol";

interface IUrdFactory {
Expand All @@ -26,7 +24,6 @@ contract UrdBundlerLocalTest is LocalTest {
function setUp() public override {
super.setUp();

bundler = new UrdBundlerMock();
urdFactory = IUrdFactory(deployCode("UrdFactory.sol", ""));
vm.label(address(urdFactory), "UrdFactory");
merkle = new Merkle();
Expand Down
13 changes: 0 additions & 13 deletions test/forge/fork/BundlerForkTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,6 @@ contract EthereumBundlerForkTest is ForkTest {
using MarketParamsLib for MarketParams;
using SafeTransferLib for ERC20;

function setUp() public override {
super.setUp();

if (block.chainid == 1) {
bundler = new EthereumBundlerV2(address(morpho));
} else if (block.chainid == 8453) {
bundler = new BaseBundlerV2(address(morpho));
}

vm.prank(USER);
morpho.setAuthorization(address(bundler), true);
}

function testSupplyWithPermit2(uint256 seed, uint256 amount, address onBehalf, uint256 privateKey, uint256 deadline)
public
{
Expand Down
12 changes: 2 additions & 10 deletions test/forge/fork/Permit2BundlerForkTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@ pragma solidity ^0.8.0;

import {ErrorsLib} from "../../../src/libraries/ErrorsLib.sol";

import "../../../src/mocks/bundlers/Permit2BundlerMock.sol";

import "./helpers/ForkTest.sol";

error InvalidNonce();

contract Permit2BundlerForkTest is ForkTest {
using SafeTransferLib for ERC20;

function setUp() public override {
super.setUp();

bundler = new Permit2BundlerMock();
}

function testApprove2(uint256 seed, uint256 privateKey, uint256 deadline, uint256 amount) public {
privateKey = bound(privateKey, 1, type(uint160).max);
deadline = bound(deadline, block.timestamp, type(uint48).max);
Expand Down Expand Up @@ -46,7 +38,7 @@ contract Permit2BundlerForkTest is ForkTest {
bytes memory signature;

vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
Permit2BundlerMock(address(bundler)).approve2(permitSingle, signature, false);
Permit2Bundler(address(bundler)).approve2(permitSingle, signature, false);
}

function testApprove2InvalidNonce(uint256 seed, uint256 privateKey, uint256 deadline, uint256 amount) public {
Expand Down Expand Up @@ -74,6 +66,6 @@ contract Permit2BundlerForkTest is ForkTest {

function testTransferFrom2Uninitiated() public {
vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
Permit2BundlerMock(address(bundler)).transferFrom2(address(0), 0);
Permit2Bundler(address(bundler)).transferFrom2(address(0), 0);
}
}
12 changes: 3 additions & 9 deletions test/forge/fork/PermitBundlerForkTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@ import {ErrorsLib} from "../../../src/libraries/ErrorsLib.sol";

import {DaiPermit} from "../helpers/SigUtils.sol";

import "../../../src/mocks/bundlers/ethereum/EthereumPermitBundlerMock.sol";
import "../../../src/ethereum/EthereumPermitBundler.sol";

import "./helpers/ForkTest.sol";

/// @dev The unique EIP-712 domain domain separator for the DAI token contract on Ethereum.
bytes32 constant DAI_DOMAIN_SEPARATOR = 0xdbb8cf42e1ecb028be3f3dbc922e1d878b963f411dc388ced501601c60f7c6f7;

contract EthereumPermitBundlerForkTest is ForkTest {
function setUp() public override {
super.setUp();

bundler = new EthereumPermitBundlerMock();
}

contract PermitBundlerForkTest is ForkTest {
function testPermitDai(uint256 privateKey, uint256 expiry) public onlyEthereum {
expiry = bound(expiry, block.timestamp, type(uint48).max);
privateKey = bound(privateKey, 1, type(uint160).max);
Expand All @@ -36,7 +30,7 @@ contract EthereumPermitBundlerForkTest is ForkTest {

function testPermitDaiUninitiated() public onlyEthereum {
vm.expectRevert(bytes(ErrorsLib.UNINITIATED));
EthereumPermitBundlerMock(address(bundler)).permitDai(0, SIGNATURE_DEADLINE, true, 0, 0, 0, true);
EthereumPermitBundler(address(bundler)).permitDai(0, SIGNATURE_DEADLINE, true, 0, 0, 0, true);
}

function testPermitDaiRevert(uint256 privateKey, uint256 expiry) public onlyEthereum {
Expand Down
Loading

0 comments on commit ccac0bf

Please sign in to comment.