You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using vm.rollFork feature in foundry to get _token.totalSupply() at two different blocks but test failing because its returning same totalSupply number for two different blocks. I have checked and totalSupply number, if tested individually for these two blocks returns different number.
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.21;
import {Test, console2} from "forge-std/Test.sol";
interface ERC20 {
function totalSupply() external view returns (uint256);
}
contract rollForkTest is Test {
uint256 mainnetFork;
ERC20 _token;
function setUp() public {
vm.createSelectFork("https://rpc.ankr.com/eth");
_token = ERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); //weth
}
function testTokenSupply() public {
vm.rollFork(17958426);
uint256 prev = _token.totalSupply();
console2.log("totalSupply prev ", prev);
console2.log("block", block.number, "timestamp", block.timestamp);
vm.rollFork(18074858);
uint256 later = _token.totalSupply();
console2.log("totalSupply later", later);
console2.log("block", block.number, "timestamp", block.timestamp);
assertNotEq(prev, later);
}
function testTokenSupplyAtBlock_17958426() public {
vm.rollFork(17958426);
console2.log("totalSupply at block 17958426 :", _token.totalSupply());
console2.log("block", block.number, "timestamp", block.timestamp);
}
function testTokenSupplyAtBlock_18074858() public {
vm.rollFork(18074858);
console2.log("totalSupply at block 18074858 :", _token.totalSupply());
console2.log("block", block.number, "timestamp", block.timestamp);
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm using vm.rollFork feature in foundry to get _token.totalSupply() at two different blocks but test failing because its returning same totalSupply number for two different blocks. I have checked and totalSupply number, if tested individually for these two blocks returns different number.
Beta Was this translation helpful? Give feedback.
All reactions