|
2 | 2 | pragma solidity ^0.8.0; |
3 | 3 |
|
4 | 4 | import '../src/contracts/DonationHandler.sol'; |
| 5 | + |
| 6 | +import './mocks/MockERC20.sol'; |
| 7 | + |
5 | 8 | import '@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol'; |
6 | | -import '@openzeppelin/contracts/token/ERC20/ERC20.sol'; |
7 | 9 | import 'forge-std/Test.sol'; |
8 | 10 |
|
9 | | -// Mock ERC20 token for testing |
10 | | -contract MockERC20 is ERC20 { |
11 | | - constructor() ERC20('MockToken', 'MTK') { |
12 | | - _mint(msg.sender, 1_000_000 * 10 ** 18); |
13 | | - } |
14 | | -} |
15 | | - |
16 | 11 | /// @title DonationHandlerBugFixTest |
17 | 12 | /// @notice Tests for the bug fix that ensures amounts array sums to totalAmount |
18 | 13 | /// @dev These tests verify the fix for the vulnerability where mismatched amounts could lock or steal ETH/tokens |
@@ -45,7 +40,7 @@ contract DonationHandlerBugFixTest is Test { |
45 | 40 | vm.deal(eve, 100 ether); |
46 | 41 |
|
47 | 42 | // Give Alice some tokens |
48 | | - mockToken.transfer(alice, 10000e18); |
| 43 | + mockToken.transfer(alice, 10_000e18); |
49 | 44 | } |
50 | 45 |
|
51 | 46 | /// @notice Test that donateManyETH reverts when amounts sum is less than totalAmount |
@@ -203,14 +198,14 @@ contract DonationHandlerBugFixTest is Test { |
203 | 198 | to[2] = alice; |
204 | 199 | to[3] = makeAddr('charlie'); |
205 | 200 | to[4] = makeAddr('dave'); |
206 | | - |
| 201 | + |
207 | 202 | uint256[] memory amts = new uint256[](5); |
208 | 203 | amts[0] = 1 ether; |
209 | 204 | amts[1] = 2 ether; |
210 | 205 | amts[2] = 3 ether; |
211 | 206 | amts[3] = 2.5 ether; |
212 | 207 | amts[4] = 1.5 ether; // Total = 10 ETH |
213 | | - |
| 208 | + |
214 | 209 | bytes[] memory data = new bytes[](5); |
215 | 210 |
|
216 | 211 | vm.prank(alice); |
|
0 commit comments