Skip to content

Commit

Permalink
fix: failing tests
Browse files Browse the repository at this point in the history
Signed-off-by: Elliot <elliotfriedman3@gmail.com>
  • Loading branch information
ElliotFriedman committed Nov 6, 2024
1 parent aecfda8 commit 19df21b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/exercises/04/SIP04.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -46,7 +47,7 @@ contract SIP04 is GovernorBravoProposal {
override
returns (string memory)
{
return name();
return "Upgrade to V4 Vault Implementation";
}

function run() public override {
Expand Down Expand Up @@ -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"),
""
);

Expand Down
2 changes: 1 addition & 1 deletion src/exercises/04/Vault04.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
21 changes: 18 additions & 3 deletions test/TestVault04.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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");
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 19df21b

Please sign in to comment.