-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected OutOfFunds Error during Testing, but Works with Forge Script #9091
Comments
@mhxw could you please add the test too,is that a fuzz test or regular? Do you run test with isolate or gas-report flag? Thank you |
I see, let me try, I suspect contract is not made persistent so it is replaced with the one from fork, here's book ref https://book.getfoundry.sh/cheatcodes/make-persistent |
Thank you for your response, and I appreciate the suggestion. I'll give it a try and look into making the contract persistent as you mentioned. |
I am not able to recreate the test but looking at traces
make sure
|
Yes, that's exactly what I did! vm.startPrank(platformAdmin); |
was this done before or after createSelectFork call? |
First, I call createSelectFork to fork the chain. After that, I deploy the contract, and finally, I execute the necessary functions. |
cool, had a look, it does seem like a legit failure, if you modify line https://github.com/mhxw/launchpad/blob/a71891b86a69ff55f0abb1bb079a2639254be77c/src/TokenFactory.sol#L438 and instead
I think you should revisit contract logic, please reopen ticket if you think still it's a foundry bug. thank you! |
I see, yes, indeed this looks like something off, reopening for further investigations. thank you |
yeah, still seems like logic related to me, if you print balance of address executing (that is the proxy) like console2.log("before send", address(this).balance);
Address.sendValue(payable(config.tokenVaultAddress), reverseAmountInActual + projectFee);
console2.log("after send", address(this).balance);
// 2. transfer token from vault to user
ITokenVault(config.tokenVaultAddress).transferAsset(recipient, tokenAmountOut);
// 3. transfer eth platform fee to platform treasury
Address.sendValue(payable(platformTreasury), platformFee);
console2.log("after send value", address(this).balance); logs shows:
so nothing left for weth.deposit call
|
ah, ok, yeah, it's annoying, we have this #4141 to improve error reporting when interacting with undeployed contracts. Are you OK to close this tracker and follow up 4141? thanks |
OK, Thank you very much, grandizzy. |
Hi @grandizzy , I previously submitted a PR to fix the image display issue. When you have some time, could you please review it? Here’s the link: |
Component
Forge, Foundryup
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (0ed43ce 2024-10-11T00:20:43.510778000Z)
What command(s) is the bug in?
forge fmt && forge clean && forge build && forge test -vvv
Operating System
macOS (Apple Silicon)
Describe the bug
I encountered an unexpected OutOfFunds error when running tests for the following contract (only core parts are shown below). However, when deploying and executing the contract using forge script, everything works perfectly, and the assets flow as expected.
Here is a simplified version of the code that led to the issue:
Traces
Steps to Reproduce:
Expected Behavior:
The contract should function properly during testing, just like it does when using forge script.
Actual Behavior:
Tests fail with an OutOfFunds error, but no such error occurs when using forge script.
The text was updated successfully, but these errors were encountered: