Skip to content
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

Can the team create a cheat code to test sending multiple transactions from an EOA in a single test function? #7571

Closed
marjon-call opened this issue Apr 5, 2024 · 4 comments

Comments

@marjon-call
Copy link

I am currently working on a Dapp that uses transient storage, and I want to test the composability of my smart contract. However, when I call a test function all interactions with the smart contract are batched under the same transaction. This is an issue because the transient storage does not get reset, and it makes it impossible to test bugs stemming from transient storage not being cleared at the end of a transaction.

In case I am not being clear enough here is an example:

function payBlockFee() stores true in transient storage. If the user has payed their block fee they are then allowed to interact with other functions in the protocol (via a multicall function). When testing, alice pays her block fee but bob is also allowed to interact with the other functions because transient storage has not been reset in the test function.

I am looking for a way to test the transaction being initiated from alice, then have a separate transaction that is initiated from bob without losing the state from alice's transaction.

@DaniPopes DaniPopes transferred this issue from foundry-rs/book Apr 5, 2024
@cruzdanilo
Copy link
Contributor

have you tried isolated execution?

  --isolate
      Whether to enable isolation of calls. In isolation mode all top-level calls are executed
      as a separate transaction in a separate EVM context, enabling more precise gas accounting
      and transaction state changes

you can also set isolate = true on foundry.toml.

@marjon-call
Copy link
Author

@cruzdanilo When I try using --isolate I get the following error message: error: unexpected argument '--isolate' found.

@cruzdanilo
Copy link
Contributor

try running foundryup to update forge. this feature is relatively new: #7186

@marjon-call
Copy link
Author

That worked, thank you!

@github-project-automation github-project-automation bot moved this from Todo to Done in Foundry Book Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

No branches or pull requests

2 participants