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

tx.origin prank does not persist through nested message calls #1210

Closed
2 tasks done
strawberry-fury opened this issue Apr 6, 2022 · 1 comment · Fixed by #1215
Closed
2 tasks done

tx.origin prank does not persist through nested message calls #1210

strawberry-fury opened this issue Apr 6, 2022 · 1 comment · Fixed by #1215
Assignees
Labels
A-cheatcodes Area: cheatcodes C-forge Command: forge Cmd-forge-test Command: forge test T-bug Type: bug

Comments

@strawberry-fury
Copy link

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (6130af7 2022-04-06T00:03:48.094239707+00:00)

What command(s) is the bug in?

forge test

Operating System

Linux

Describe the bug

Minimal code and steps to replicate:
https://gist.github.com/strawberry-fury/ade15e042494d9fa6a1bfac7bfbce660
After running forge init in an empty directory, put the above code in a .sol file in src/, then run forge test.
The test will fail because the assertEq on line 43 fails, but in reality it shouldn't.

If Line 31 (transfer() on the dummy ERC20) is commented out, the test passes.
This leads me to believe that it's due to the behavior that after any message call finishes, the tx.origin prank is over.

@strawberry-fury strawberry-fury added the T-bug Type: bug label Apr 6, 2022
@onbjerg onbjerg self-assigned this Apr 6, 2022
@onbjerg onbjerg added Cmd-forge-test Command: forge test C-forge Command: forge A-cheatcodes Area: cheatcodes labels Apr 6, 2022
onbjerg added a commit that referenced this issue Apr 6, 2022
@onbjerg
Copy link
Collaborator

onbjerg commented Apr 6, 2022

Good catch, fixed in #1215 which will be released tonight if merged. In the meantime startPrank/stopPrank does not have this bug

gakonst pushed a commit that referenced this issue Apr 7, 2022
* fix: correct depth where we check expected emits

* fix: don't reset `tx.origin` too early

Closes #1210
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cheatcodes Area: cheatcodes C-forge Command: forge Cmd-forge-test Command: forge test T-bug Type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants