From 750df11a8aae69d3bf8afffc6a2bc432229bec22 Mon Sep 17 00:00:00 2001 From: danilo neves cruz Date: Tue, 31 Dec 2024 11:55:06 +0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20contracts:=20inject=20test=20deploy?= =?UTF-8?q?ments=20through=20custom=20setups?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contracts/.gas-snapshot | 78 ++++++++++---------- contracts/script/Deploy.s.sol | 49 +++++++++--- contracts/script/InstallmentsPreviewer.s.sol | 12 ++- contracts/script/IssuerChecker.s.sol | 15 +++- contracts/script/Refunder.s.sol | 20 +++-- contracts/test/ExaPlugin.t.sol | 34 ++------- contracts/test/InstallmentsPreviewer.t.sol | 8 +- contracts/test/MockSwapper.t.sol | 7 +- contracts/test/Refunder.t.sol | 5 -- contracts/test/mocks/Mocks.s.sol | 5 ++ 10 files changed, 128 insertions(+), 105 deletions(-) diff --git a/contracts/.gas-snapshot b/contracts/.gas-snapshot index 825fb347..e6dd1b98 100644 --- a/contracts/.gas-snapshot +++ b/contracts/.gas-snapshot @@ -1,50 +1,50 @@ ExaAccountFactoryTest:testFuzz_createAccount_EOAOwners(uint256,address[63]) (runs: 256, μ: 3621366, ~: 3460632) -ExaPluginTest:testFork_crossRepay_repays() (gas: 19666737) -ExaPluginTest:testFork_debitCollateral_collects() (gas: 19756315) -ExaPluginTest:testFork_swap_swaps() (gas: 16912274) +ExaPluginTest:testFork_crossRepay_repays() (gas: 19662215) +ExaPluginTest:testFork_debitCollateral_collects() (gas: 19751793) +ExaPluginTest:testFork_swap_swaps() (gas: 16907764) ExaPluginTest:test_borrowAtMaturity_reverts_withUnauthorized_whenReceiverNotCollector() (gas: 408975) ExaPluginTest:test_borrow_reverts_withUnauthorized_whenReceiverNotCollector() (gas: 408553) ExaPluginTest:test_collectCredit_collects() (gas: 921083) -ExaPluginTest:test_collectCredit_collects_whenHealthFactorHigherThanMinHealthFactor() (gas: 801758) +ExaPluginTest:test_collectCredit_collects_whenHealthFactorHigherThanMinHealthFactor() (gas: 801746) ExaPluginTest:test_collectCredit_collects_withEnoughSlippage() (gas: 800271) -ExaPluginTest:test_collectCredit_passes_whenProposalLeavesEnoughLiquidity() (gas: 1010088) +ExaPluginTest:test_collectCredit_passes_whenProposalLeavesEnoughLiquidity() (gas: 1010124) ExaPluginTest:test_collectCredit_reverts_asNotKeeper() (gas: 362757) ExaPluginTest:test_collectCredit_reverts_whenDisagreement() (gas: 556074) -ExaPluginTest:test_collectCredit_reverts_whenExpired() (gas: 358845) -ExaPluginTest:test_collectCredit_reverts_whenHealthFactorLowerThanMinHealthFactor() (gas: 832014) -ExaPluginTest:test_collectCredit_reverts_whenPrposalCausesInsufficientLiquidity() (gas: 1010277) +ExaPluginTest:test_collectCredit_reverts_whenExpired() (gas: 358857) +ExaPluginTest:test_collectCredit_reverts_whenHealthFactorLowerThanMinHealthFactor() (gas: 832002) +ExaPluginTest:test_collectCredit_reverts_whenPrposalCausesInsufficientLiquidity() (gas: 1010301) ExaPluginTest:test_collectCredit_reverts_whenReplay() (gas: 843323) -ExaPluginTest:test_collectCredit_reverts_whenTimelocked() (gas: 355114) +ExaPluginTest:test_collectCredit_reverts_whenTimelocked() (gas: 355102) ExaPluginTest:test_collectCredit_toleratesTimeDrift() (gas: 803748) ExaPluginTest:test_collectDebit_collects() (gas: 651749) -ExaPluginTest:test_collectDebit_collects_whenProposalLeavesEnoughLiquidity() (gas: 855108) +ExaPluginTest:test_collectDebit_collects_whenProposalLeavesEnoughLiquidity() (gas: 855132) ExaPluginTest:test_collectDebit_reverts_asNotKeeper() (gas: 362589) -ExaPluginTest:test_collectDebit_reverts_whenExpired() (gas: 358651) -ExaPluginTest:test_collectDebit_reverts_whenProposalCausesInsufficientLiquidity() (gas: 852099) +ExaPluginTest:test_collectDebit_reverts_whenExpired() (gas: 358663) +ExaPluginTest:test_collectDebit_reverts_whenProposalCausesInsufficientLiquidity() (gas: 852123) ExaPluginTest:test_collectDebit_reverts_whenReplay() (gas: 691191) -ExaPluginTest:test_collectDebit_reverts_whenTimelocked() (gas: 354855) +ExaPluginTest:test_collectDebit_reverts_whenTimelocked() (gas: 354843) ExaPluginTest:test_collectDebit_toleratesTimeDrift() (gas: 651826) -ExaPluginTest:test_collectInstallments_collects() (gas: 1338830) -ExaPluginTest:test_collectInstallments_revertsWhenNoSlippage() (gas: 1203025) +ExaPluginTest:test_collectInstallments_collects() (gas: 1338854) +ExaPluginTest:test_collectInstallments_revertsWhenNoSlippage() (gas: 1203049) ExaPluginTest:test_collectInstallments_reverts_asNotKeeper() (gas: 363607) -ExaPluginTest:test_collectInstallments_reverts_whenExpired() (gas: 361030) +ExaPluginTest:test_collectInstallments_reverts_whenExpired() (gas: 361018) ExaPluginTest:test_collectInstallments_reverts_whenReplay() (gas: 1070925) -ExaPluginTest:test_collectInstallments_reverts_whenTimelocked() (gas: 357218) +ExaPluginTest:test_collectInstallments_reverts_whenTimelocked() (gas: 357206) ExaPluginTest:test_collectInstallments_toleratesTimeDrift() (gas: 1195516) ExaPluginTest:test_crossRepay_repays() (gas: 1466544) ExaPluginTest:test_crossRepay_repays_whenKeeper() (gas: 1463190) ExaPluginTest:test_crossRepay_reverts_whenDisagreement() (gas: 1575464) ExaPluginTest:test_crossRepay_reverts_whenNotKeeper() (gas: 961090) -ExaPluginTest:test_debitCollateral_collects() (gas: 776959) +ExaPluginTest:test_debitCollateral_collects() (gas: 776947) ExaPluginTest:test_exitMarket_reverts() (gas: 389259) ExaPluginTest:test_onUninstall_uninstalls() (gas: 284122) ExaPluginTest:test_poke() (gas: 315952) ExaPluginTest:test_pokeETH_deposits() (gas: 375965) -ExaPluginTest:test_propose_emitsProposed() (gas: 218655) -ExaPluginTest:test_refund_refunds() (gas: 361505) -ExaPluginTest:test_repay_partiallyRepays() (gas: 1250119) +ExaPluginTest:test_propose_emitsProposed() (gas: 218667) +ExaPluginTest:test_refund_refunds() (gas: 361517) +ExaPluginTest:test_repay_partiallyRepays() (gas: 1250131) ExaPluginTest:test_repay_partiallyRepays_whenKeeper() (gas: 1192284) -ExaPluginTest:test_repay_repays() (gas: 1166226) +ExaPluginTest:test_repay_repays() (gas: 1166238) ExaPluginTest:test_repay_repays_whenKeeper() (gas: 1108950) ExaPluginTest:test_rollDebt_rolls() (gas: 1234108) ExaPluginTest:test_rollDebt_rolls_asKeeper() (gas: 1233734) @@ -57,28 +57,28 @@ ExaPluginTest:test_setMinHealthFactor_reverts_whenNotAdmin() (gas: 33768) ExaPluginTest:test_setMinHealthFactor_sets_whenAdmin() (gas: 39463) ExaPluginTest:test_swap_reverts_withDisagreement() (gas: 289042) ExaPluginTest:test_swap_swaps() (gas: 268686) -ExaPluginTest:test_withdrawWETH_transfersETH() (gas: 848687) -ExaPluginTest:test_withdraw_reverts_whenNoProposal() (gas: 415178) +ExaPluginTest:test_withdrawWETH_transfersETH() (gas: 848711) +ExaPluginTest:test_withdraw_reverts_whenNoProposal() (gas: 415202) ExaPluginTest:test_withdraw_reverts_whenNoProposalKeeper() (gas: 358000) ExaPluginTest:test_withdraw_reverts_whenNotKeeper() (gas: 355018) -ExaPluginTest:test_withdraw_reverts_whenReceiverIsContractAndMarketNotWETH() (gas: 621314) -ExaPluginTest:test_withdraw_reverts_whenTimelocked() (gas: 307315) -ExaPluginTest:test_withdraw_reverts_whenTimelockedKeeper() (gas: 309148) -ExaPluginTest:test_withdraw_reverts_whenWrongAmount() (gas: 308712) -ExaPluginTest:test_withdraw_reverts_whenWrongMarket() (gas: 309038) -ExaPluginTest:test_withdraw_reverts_whenWrongReceiver() (gas: 308405) -ExaPluginTest:test_withdraw_transfersAsset_asKeeper() (gas: 820334) -ExaPluginTest:test_withdraw_transfersAsset_asOwner() (gas: 819025) +ExaPluginTest:test_withdraw_reverts_whenReceiverIsContractAndMarketNotWETH() (gas: 621338) +ExaPluginTest:test_withdraw_reverts_whenTimelocked() (gas: 307363) +ExaPluginTest:test_withdraw_reverts_whenTimelockedKeeper() (gas: 309172) +ExaPluginTest:test_withdraw_reverts_whenWrongAmount() (gas: 308760) +ExaPluginTest:test_withdraw_reverts_whenWrongMarket() (gas: 309086) +ExaPluginTest:test_withdraw_reverts_whenWrongReceiver() (gas: 308429) +ExaPluginTest:test_withdraw_transfersAsset_asKeeper() (gas: 820346) +ExaPluginTest:test_withdraw_transfersAsset_asOwner() (gas: 819049) InstallmentsPreviewerTest:test_preview_returns() (gas: 135598) IssuerCheckerTest:test_setIssuer_emits_IssuerSet() (gas: 41782) IssuerCheckerTest:test_setIssuer_reverts_whenNotAdmin() (gas: 37070) IssuerCheckerTest:test_setIssuer_reverts_whenZeroAddress() (gas: 35449) -MockSwapperTest:test_swapExactAmountIn_swaps() (gas: 220530) -MockSwapperTest:test_swapExactAmountOut_swaps() (gas: 220657) -RefunderTest:test_refund_refunds() (gas: 242371) -RefunderTest:test_refund_reverts_whenExpired() (gas: 69551) -RefunderTest:test_refund_reverts_whenNotKeeper() (gas: 56897) -RefunderTest:test_refund_reverts_whenReplay() (gas: 279261) -RefunderTest:test_refund_reverts_whenTimelocked() (gas: 63310) +MockSwapperTest:test_swapExactAmountIn_swaps() (gas: 220542) +MockSwapperTest:test_swapExactAmountOut_swaps() (gas: 220669) +RefunderTest:test_refund_refunds() (gas: 242383) +RefunderTest:test_refund_reverts_whenExpired() (gas: 69563) +RefunderTest:test_refund_reverts_whenNotKeeper() (gas: 56909) +RefunderTest:test_refund_reverts_whenReplay() (gas: 279285) +RefunderTest:test_refund_reverts_whenTimelocked() (gas: 63298) RefunderTest:test_refund_reverts_whenWrongSignature() (gas: 68975) RefunderTest:test_refund_toleratesTimeDrift() (gas: 242469) \ No newline at end of file diff --git a/contracts/script/Deploy.s.sol b/contracts/script/Deploy.s.sol index 8199edf1..0e4573f6 100644 --- a/contracts/script/Deploy.s.sol +++ b/contracts/script/Deploy.s.sol @@ -15,43 +15,42 @@ import { BaseScript } from "./Base.s.sol"; contract DeployScript is BaseScript { ExaAccountFactory public factory; ExaPlugin public exaPlugin; - IssuerChecker public issuerChecker; - WebauthnOwnerPlugin public ownerPlugin; + IAuditor public auditor; IMarket public exaUSDC; IMarket public exaWETH; IDebtManager public debtManager; IInstallmentsRouter public installmentsRouter; - Refunder public refunder; IBalancerVault public balancerVault; - + WebauthnOwnerPlugin public ownerPlugin; + IssuerChecker public issuerChecker; + Refunder public refunder; address public admin; address public keeper; - address public deployer; address public collector; address public swapper; function setUp() external { - ownerPlugin = WebauthnOwnerPlugin(dependency("webauthn-owner-plugin", "WebauthnOwnerPlugin", "Plugin", 0)); - issuerChecker = IssuerChecker(broadcast("IssuerChecker")); auditor = IAuditor(protocol("Auditor")); exaUSDC = IMarket(protocol("MarketUSDC")); exaWETH = IMarket(protocol("MarketWETH")); debtManager = IDebtManager(protocol("DebtManager")); installmentsRouter = IInstallmentsRouter(protocol("InstallmentsRouter")); - refunder = Refunder(broadcast("Refunder")); - balancerVault = IBalancerVault(protocol("BalancerVault")); + ownerPlugin = WebauthnOwnerPlugin(dependency("webauthn-owner-plugin", "WebauthnOwnerPlugin", "Plugin", 0)); + + issuerChecker = IssuerChecker(broadcast("IssuerChecker")); + refunder = Refunder(broadcast("Refunder")); + admin = acct("admin"); keeper = acct("keeper"); - deployer = acct("deployer"); collector = acct("collector"); swapper = acct("swapper"); } function run() external { - vm.startBroadcast(deployer); + vm.startBroadcast(acct("deployer")); exaPlugin = new ExaPlugin( admin, @@ -72,4 +71,32 @@ contract DeployScript is BaseScript { vm.stopBroadcast(); } + + function _setUp( + IAuditor auditor_, + IMarket exaUSDC_, + IMarket exaWETH_, + IDebtManager debtManager_, + IInstallmentsRouter installmentsRouter_, + IBalancerVault balancerVault_, + WebauthnOwnerPlugin ownerPlugin_, + IssuerChecker issuerChecker_, + Refunder refunder_, + address keeper_, + address swapper_ + ) external { + auditor = auditor_; + exaUSDC = exaUSDC_; + exaWETH = exaWETH_; + debtManager = debtManager_; + installmentsRouter = installmentsRouter_; + balancerVault = balancerVault_; + ownerPlugin = ownerPlugin_; + issuerChecker = issuerChecker_; + refunder = refunder_; + keeper = keeper_; + swapper = swapper_; + collector = msg.sender; + admin = msg.sender; + } } diff --git a/contracts/script/InstallmentsPreviewer.s.sol b/contracts/script/InstallmentsPreviewer.s.sol index 472302bf..2667b1a4 100644 --- a/contracts/script/InstallmentsPreviewer.s.sol +++ b/contracts/script/InstallmentsPreviewer.s.sol @@ -8,8 +8,18 @@ import { BaseScript } from "./Base.s.sol"; contract DeployInstallmentsPreviewer is BaseScript { InstallmentsPreviewer public installmentsPreviewer; + ICollectableMarket public exaUSDC; + + function setUp() external { + exaUSDC = ICollectableMarket(protocol("MarketUSDC")); + } + function run() external { vm.broadcast(acct("deployer")); - installmentsPreviewer = new InstallmentsPreviewer(ICollectableMarket(protocol("MarketUSDC"))); + installmentsPreviewer = new InstallmentsPreviewer(exaUSDC); + } + + function _setUp(ICollectableMarket exaUSDC_) external { + exaUSDC = exaUSDC_; } } diff --git a/contracts/script/IssuerChecker.s.sol b/contracts/script/IssuerChecker.s.sol index 3bb6e215..13051aae 100644 --- a/contracts/script/IssuerChecker.s.sol +++ b/contracts/script/IssuerChecker.s.sol @@ -8,8 +8,21 @@ import { BaseScript } from "./Base.s.sol"; contract DeployIssuerChecker is BaseScript { IssuerChecker public issuerChecker; + address public admin; + address public issuer; + + function setUp() external { + admin = acct("admin"); + issuer = acct("issuer"); + } + function run() external { vm.broadcast(acct("deployer")); - issuerChecker = new IssuerChecker(acct("admin"), acct("issuer")); + issuerChecker = new IssuerChecker(admin, issuer); + } + + function _setUp(address issuer_) external { + issuer = issuer_; + admin = msg.sender; } } diff --git a/contracts/script/Refunder.s.sol b/contracts/script/Refunder.s.sol index f064607a..25bb03a9 100644 --- a/contracts/script/Refunder.s.sol +++ b/contracts/script/Refunder.s.sol @@ -6,23 +6,29 @@ import { IMarket, IssuerChecker, Refunder } from "../src/Refunder.sol"; import { BaseScript } from "./Base.s.sol"; contract DeployRefunder is BaseScript { - IMarket public exaUSDC; - IssuerChecker public issuerChecker; Refunder public refunder; + IMarket public exaUSDC; + IssuerChecker public issuerChecker; + address public admin; address public keeper; - address public deployer; function setUp() external { exaUSDC = IMarket(protocol("MarketUSDC")); issuerChecker = IssuerChecker(broadcast("IssuerChecker")); - + admin = acct("admin"); keeper = acct("keeper"); - deployer = acct("deployer"); } function run() external { - vm.broadcast(deployer); - refunder = new Refunder(acct("admin"), exaUSDC, issuerChecker, keeper); + vm.broadcast(acct("deployer")); + refunder = new Refunder(admin, exaUSDC, issuerChecker, keeper); + } + + function _setUp(IMarket exaUSDC_, IssuerChecker issuerChecker_, address keeper_) external { + exaUSDC = exaUSDC_; + issuerChecker = issuerChecker_; + keeper = keeper_; + admin = msg.sender; } } diff --git a/contracts/test/ExaPlugin.t.sol b/contracts/test/ExaPlugin.t.sol index d1095455..0fae668b 100644 --- a/contracts/test/ExaPlugin.t.sol +++ b/contracts/test/ExaPlugin.t.sol @@ -18,7 +18,6 @@ import { Address } from "openzeppelin-contracts/contracts/utils/Address.sol"; import { ECDSA } from "solady/utils/ECDSA.sol"; import { FixedPointMathLib } from "solady/utils/FixedPointMathLib.sol"; -import { LibString } from "solady/utils/LibString.sol"; import { MockERC20 } from "solmate/src/test/utils/mocks/MockERC20.sol"; @@ -60,7 +59,6 @@ import { DeployProtocol } from "./mocks/Protocol.s.sol"; contract ExaPluginTest is ForkTest { using FixedPointMathLib for uint256; using OwnersLib for address[]; - using LibString for address; using Address for address; using ECDSA for bytes32; @@ -87,16 +85,12 @@ contract ExaPluginTest is ForkTest { MockERC20 internal usdc; function setUp() external { - vm.setEnv("DEPLOYER_ADDRESS", address(this).toHexString()); - collector = payable(makeAddr("collector")); (owner, ownerKey) = makeAddrAndKey("owner"); owners = new address[](1); owners[0] = owner; (keeper, keeperKey) = makeAddrAndKey("keeper"); (issuer, issuerKey) = makeAddrAndKey("issuer"); - vm.setEnv("KEEPER_ADDRESS", keeper.toHexString()); - vm.setEnv("ISSUER_ADDRESS", issuer.toHexString()); new DeployAccount().run(); DeployProtocol p = new DeployProtocol(); @@ -107,25 +101,20 @@ contract ExaPluginTest is ForkTest { exaWETH = IMarket(address(p.exaWETH())); exa = p.exa(); usdc = p.usdc(); - vm.setEnv("PROTOCOL_AUDITOR_ADDRESS", address(auditor).toHexString()); - vm.setEnv("PROTOCOL_MARKETUSDC_ADDRESS", address(exaUSDC).toHexString()); - vm.setEnv("PROTOCOL_USDC_ADDRESS", address(usdc).toHexString()); - - DeployMocks m = new DeployMocks(); - m.setUp(); - m.run(); - vm.setEnv("SWAPPER_ADDRESS", address(m.swapper()).toHexString()); DeployIssuerChecker ic = new DeployIssuerChecker(); + ic._setUp(issuer); ic.run(); issuerChecker = ic.issuerChecker(); - vm.setEnv("BROADCAST_ISSUERCHECKER_ADDRESS", address(issuerChecker).toHexString()); + + DeployMocks m = new DeployMocks(); + m._setUp(auditor, usdc); + m.run(); DeployRefunder r = new DeployRefunder(); - r.setUp(); + r._setUp(exaUSDC, issuerChecker, keeper); r.run(); refunder = r.refunder(); - vm.setEnv("BROADCAST_REFUNDER_ADDRESS", address(refunder).toHexString()); exaPlugin = new ExaPlugin( address(this), @@ -1215,17 +1204,6 @@ contract ExaPluginTest is ForkTest { function _setUpLifiFork() internal { vm.createSelectFork("optimism", 127_050_624); account = ExaAccount(payable(0x6120Fb2A9d47f7955298b80363F00C620dB9f6E6)); - - vm.setEnv("DEPLOYER_ADDRESS", ""); - vm.setEnv("KEEPER_ADDRESS", ""); - vm.setEnv("ISSUER_ADDRESS", ""); - vm.setEnv("SWAPPER_ADDRESS", ""); - vm.setEnv("PROTOCOL_AUDITOR_ADDRESS", ""); - vm.setEnv("PROTOCOL_MARKETUSDC_ADDRESS", ""); - vm.setEnv("PROTOCOL_USDC_ADDRESS", ""); - vm.setEnv("BROADCAST_ISSUERCHECKER_ADDRESS", ""); - vm.setEnv("BROADCAST_REFUNDER_ADDRESS", ""); - issuerChecker = IssuerChecker(broadcast("IssuerChecker")); vm.prank(acct("deployer")); issuerChecker.setIssuer(issuer); diff --git a/contracts/test/InstallmentsPreviewer.t.sol b/contracts/test/InstallmentsPreviewer.t.sol index 367c3633..606093e8 100644 --- a/contracts/test/InstallmentsPreviewer.t.sol +++ b/contracts/test/InstallmentsPreviewer.t.sol @@ -3,27 +3,21 @@ pragma solidity ^0.8.0; import { ForkTest } from "./Fork.t.sol"; -import { LibString } from "solady/utils/LibString.sol"; - import { DeployInstallmentsPreviewer } from "../script/InstallmentsPreviewer.s.sol"; import { ICollectableMarket, InstallmentsPreviewer } from "../src/InstallmentsPreviewer.sol"; import { DeployProtocol } from "./mocks/Protocol.s.sol"; contract InstallmentsPreviewerTest is ForkTest { - using LibString for address; - ICollectableMarket internal exaUSDC; InstallmentsPreviewer internal previewer; function setUp() external { - vm.setEnv("DEPLOYER_ADDRESS", address(this).toHexString()); - DeployProtocol p = new DeployProtocol(); p.run(); exaUSDC = ICollectableMarket(address(p.exaUSDC())); - vm.setEnv("PROTOCOL_MARKETUSDC_ADDRESS", address(exaUSDC).toHexString()); DeployInstallmentsPreviewer ip = new DeployInstallmentsPreviewer(); + ip._setUp(exaUSDC); ip.run(); previewer = ip.installmentsPreviewer(); } diff --git a/contracts/test/MockSwapper.t.sol b/contracts/test/MockSwapper.t.sol index ed2a8bb6..92826571 100644 --- a/contracts/test/MockSwapper.t.sol +++ b/contracts/test/MockSwapper.t.sol @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.0; -import { LibString } from "solady/utils/LibString.sol"; import { MockERC20 } from "solmate/src/test/utils/mocks/MockERC20.sol"; import { ForkTest } from "./Fork.t.sol"; @@ -10,8 +9,6 @@ import { DeployMocks } from "./mocks/Mocks.s.sol"; import { DeployProtocol } from "./mocks/Protocol.s.sol"; contract MockSwapperTest is ForkTest { - using LibString for address; - MockSwapper internal mockSwapper; MockERC20 internal exa; MockERC20 internal usdc; @@ -21,11 +18,9 @@ contract MockSwapperTest is ForkTest { p.run(); exa = p.exa(); usdc = p.usdc(); - vm.setEnv("PROTOCOL_AUDITOR_ADDRESS", address(p.auditor()).toHexString()); - vm.setEnv("PROTOCOL_USDC_ADDRESS", address(usdc).toHexString()); DeployMocks m = new DeployMocks(); - m.setUp(); + m._setUp(p.auditor(), usdc); m.run(); mockSwapper = m.swapper(); diff --git a/contracts/test/Refunder.t.sol b/contracts/test/Refunder.t.sol index 21e1f4a4..5d75af45 100644 --- a/contracts/test/Refunder.t.sol +++ b/contracts/test/Refunder.t.sol @@ -3,8 +3,6 @@ pragma solidity ^0.8.0; import { ForkTest } from "./Fork.t.sol"; -import { LibString } from "solady/utils/LibString.sol"; - import { MockERC20 } from "solmate/src/test/utils/mocks/MockERC20.sol"; import { IMarket, Unauthorized } from "../src/IExaAccount.sol"; @@ -13,8 +11,6 @@ import { Refunder } from "../src/Refunder.sol"; import { DeployProtocol } from "./mocks/Protocol.s.sol"; contract RefunderTest is ForkTest { - using LibString for address; - address internal keeper; uint256 internal keeperKey; address internal issuer; @@ -28,7 +24,6 @@ contract RefunderTest is ForkTest { address internal bob = address(0xb0b); function setUp() external { - vm.setEnv("DEPLOYER_ADDRESS", address(this).toHexString()); DeployProtocol p = new DeployProtocol(); p.run(); diff --git a/contracts/test/mocks/Mocks.s.sol b/contracts/test/mocks/Mocks.s.sol index a0998d47..f8462967 100644 --- a/contracts/test/mocks/Mocks.s.sol +++ b/contracts/test/mocks/Mocks.s.sol @@ -55,4 +55,9 @@ contract DeployMocks is BaseScript { vm.stopBroadcast(); } + + function _setUp(Auditor auditor_, MockERC20 usdc_) external { + auditor = auditor_; + usdc = usdc_; + } }