forked from decentxyz/forge-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBalanceAssertions.sol
42 lines (37 loc) · 1.03 KB
/
BalanceAssertions.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import {BaseChainSetup} from "./BaseChainSetup.sol";
import {ERC20} from "solmate/tokens/ERC20.sol";
import {Test} from "forge-std/Test.sol";
contract BalanceAssertions is BaseChainSetup, Test {
function assertTokenBalanceEq(
string memory chain,
address user,
address token,
uint256 amount
) internal {
switchTo(chain);
assertEq(ERC20(token).balanceOf(user), amount);
}
function assertWethBalanceEq(
string memory chain,
address user,
uint256 amount
) internal {
assertTokenBalanceEq(chain, user, wethLookup[chain], amount);
}
function assertEthBalanceEq(
string memory chain,
address user,
uint256 amount
) internal {
assertEq(ethBalance(chain, user), amount);
}
function ethBalance(
string memory chain,
address user
) internal returns (uint256) {
switchTo(chain);
return user.balance;
}
}