Skip to content

Commit 47e4550

Browse files
committed
fix: strategy unit tests
1 parent 31c18c6 commit 47e4550

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

src/test/mocks/ERC20Mock.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ contract ERC20Mock is Context, IERC20 {
4646
constructor() {
4747
_mint(msg.sender, initSupply);
4848
}
49+
50+
/**
51+
* @dev Returns the decimals places of the token.
52+
*/
53+
function decimals() external pure returns (uint8) {
54+
return 18;
55+
}
4956

5057
/**
5158
* @dev See {IERC20-totalSupply}.

src/test/mocks/MockDecimals.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// SPDX-License-Identifier: BUSL-1.1
2+
pragma solidity ^0.8.12;
3+
4+
contract MockDecimals {
5+
function decimals() public pure returns (uint8) {
6+
return 18;
7+
}
8+
}

src/test/mocks/Reverter.sol

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
pragma solidity ^0.8.9;
33

44
contract Reverter {
5-
65
fallback() external {
76
revert("Reverter: I am a contract that always reverts");
87
}
8+
}
9+
10+
contract ReverterWithDecimals is Reverter {
11+
function decimals() external pure returns (uint8) {
12+
return 18;
13+
}
914
}

src/test/unit/StrategyManagerUnit.t.sol

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import "src/test/mocks/ERC20Mock.sol";
99
import "src/test/mocks/ERC20_SetTransferReverting_Mock.sol";
1010
import "src/test/mocks/Reverter.sol";
1111
import "src/test/mocks/Reenterer.sol";
12+
import "src/test/mocks/MockDecimals.sol";
1213
import "src/test/events/IStrategyManagerEvents.sol";
1314
import "src/test/utils/EigenLayerUnitTestSetup.sol";
1415

@@ -367,7 +368,7 @@ contract StrategyManagerUnitTests_depositIntoStrategy is StrategyManagerUnitTest
367368

368369
function test_Revert_WhenTokenSafeTransferFromReverts() external {
369370
// replace 'dummyStrat' with one that uses a reverting token
370-
dummyToken = IERC20(address(new Reverter()));
371+
dummyToken = IERC20(address(new ReverterWithDecimals()));
371372
dummyStrat = _deployNewStrategy(dummyToken, strategyManager, pauserRegistry, dummyAdmin);
372373

373374
// whitelist the strategy for deposit
@@ -390,8 +391,8 @@ contract StrategyManagerUnitTests_depositIntoStrategy is StrategyManagerUnitTest
390391
}
391392

392393
function test_Revert_WhenTokenDoesNotExist() external {
393-
// replace 'dummyStrat' with one that uses a non-existent token
394-
dummyToken = IERC20(address(5678));
394+
// replace 'dummyStrat' with one that uses a non-existent token, but will pass the initializer decimals check
395+
dummyToken = IERC20(address(new MockDecimals()));
395396
dummyStrat = _deployNewStrategy(dummyToken, strategyManager, pauserRegistry, dummyAdmin);
396397

397398
// whitelist the strategy for deposit
@@ -408,7 +409,7 @@ contract StrategyManagerUnitTests_depositIntoStrategy is StrategyManagerUnitTest
408409
IStrategy strategy = dummyStrat;
409410

410411
cheats.prank(staker);
411-
cheats.expectRevert("Address: call to non-contract");
412+
cheats.expectRevert("SafeERC20: low-level call failed");
412413
strategyManager.depositIntoStrategy(strategy, token, amount);
413414
}
414415

0 commit comments

Comments
 (0)