I'm testing using foundry. Isn't it correct syntax for balanceOf ? I don'k know why but it keeps revert.
assertEq(IERC20(address(ico)).balanceOf(address(attacker)), 10 * ONE_TOKEN);
use the following code
console.log(IERC20(address(ico)).balanceOf(address(attacker)));
assertEq(IERC20(address(ico)).balanceOf(address(attacker)), 10 * ONE_TOKEN);
This will print out the current balance of the attacker address in the console, which can help you determine if the issue is with the balanceOf function call or the assertion itself.
One thing that tripped me up is that not all forge commands use the ETH_RPC_URL
environment variable. Make sure the --rpc-url
argument is set when you run your command, otherwise onchain calls will revert.
E.g. forge create and cast send use the environment variable, while forge test and forge script do not.