I work with Foundry (Forge, Anvil, Cast).
According to their documentation one can run a gas estimation for the tests one has written.
I have a very simple test for which I wanted to have a gas estimate, because I could then infer how much gas this function call (I'm talking about (withdraw)) approx. uses.
function testWithdrawIsolated() public {
vm.startPrank(whitelistedAddresses[0]); // <- withdraw can only called by owner, this is the owner
cryptoDevs.withdraw();
}
It reported CryptoDevsTest:testWithdrawIsolated() (gas: 13113)
So I assumed withdraw uses approx. less than 13k gas.
However, when I ran the withdraw function in remix with my browser wallet, 5 times out of 5 it ran with 30621 Gas.
My Question
Why is the gas amount so different?