From 19df21b512ff35fadd23b1b6b2fd0ee908ed3dfa Mon Sep 17 00:00:00 2001 From: Elliot Date: Wed, 6 Nov 2024 13:58:06 +0700 Subject: [PATCH] fix: failing tests Signed-off-by: Elliot --- src/exercises/04/SIP04.sol | 7 ++++--- src/exercises/04/Vault04.sol | 2 +- test/TestVault04.t.sol | 21 ++++++++++++++++++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/exercises/04/SIP04.sol b/src/exercises/04/SIP04.sol index 94cd5fa..0aaade3 100644 --- a/src/exercises/04/SIP04.sol +++ b/src/exercises/04/SIP04.sol @@ -34,10 +34,11 @@ contract SIP04 is GovernorBravoProposal { chainIds[0] = 1; setAddresses(new Addresses(addressesFolderPath, chainIds)); + setGovernor(addresses.getAddress("COMPOUND_GOVERNOR_BRAVO")); } function name() public pure override returns (string memory) { - return "SIP-03 Upgrade"; + return "SIP-04"; } function description() @@ -46,7 +47,7 @@ contract SIP04 is GovernorBravoProposal { override returns (string memory) { - return name(); + return "Upgrade to V4 Vault Implementation"; } function run() public override { @@ -80,7 +81,7 @@ contract SIP04 is GovernorBravoProposal { // upgrade to new implementation ProxyAdmin(proxyAdmin).upgradeAndCall( ITransparentUpgradeableProxy(vaultProxy), - addresses.getAddress("V4_VAULT_IMPLEMENTATION"), + addresses.getAddress("V4_VAULT_IMPL"), "" ); diff --git a/src/exercises/04/Vault04.sol b/src/exercises/04/Vault04.sol index 52fec78..6f0d243 100644 --- a/src/exercises/04/Vault04.sol +++ b/src/exercises/04/Vault04.sol @@ -196,7 +196,7 @@ contract Vault is VaultStoragePausable { uint8 decimals = IERC20Metadata(token).decimals(); normalizedAmount = amount; if (decimals < 18) { - normalizedAmount = amount ** (10 * (18 - decimals)); + normalizedAmount = amount * (10 ** (18 - decimals)); } } } diff --git a/test/TestVault04.t.sol b/test/TestVault04.t.sol index fa8b058..0a536c1 100644 --- a/test/TestVault04.t.sol +++ b/test/TestVault04.t.sol @@ -3,12 +3,13 @@ pragma solidity ^0.8.0; import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; -import {Test} from "@forge-std/Test.sol"; +import {Test, console} from "@forge-std/Test.sol"; -import {SIP02} from "src/exercises/02/SIP02.sol"; +import {SIP03} from "src/exercises/03/SIP03.sol"; +import {SIP04} from "src/exercises/04/SIP04.sol"; import {Vault} from "src/exercises/04/Vault04.sol"; -contract TestVault04 is Test, SIP02 { +contract TestVault04 is Test, SIP04 { using SafeERC20 for IERC20; Vault public vault; @@ -32,14 +33,26 @@ contract TestVault04 is Test, SIP02 { vm.setEnv("DO_PRINT", "false"); vm.setEnv("DO_VALIDATE", "false"); + SIP03 sip03 = new SIP03(); + + sip03.setupProposal(); + sip03.deploy(); + /// setup the proposal setupProposal(); + /// copy SIP03 addresses into this contract for integration testing + setAddresses(sip03.addresses()); + /// run the proposal vm.startPrank(addresses.getAddress("DEPLOYER_EOA")); deploy(); vm.stopPrank(); + /// build and run proposal + build(); + simulate(); + dai = addresses.getAddress("DAI"); usdc = addresses.getAddress("USDC"); usdt = addresses.getAddress("USDT"); @@ -76,7 +89,9 @@ contract TestVault04 is Test, SIP02 { function testWithdrawAlreadyDepositedUSDC() public { uint256 usdcDepositAmount = 1_000e6; + _vaultDeposit(usdc, address(this), usdcDepositAmount); + vault.withdraw(usdc, usdcDepositAmount); }