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

[Feature]: Allow setting msg::sender in unit tests #12

Closed
alexfertel opened this issue Apr 3, 2024 · 2 comments · Fixed by #14
Closed

[Feature]: Allow setting msg::sender in unit tests #12

alexfertel opened this issue Apr 3, 2024 · 2 comments · Fixed by #14

Comments

@alexfertel
Copy link

No description provided.

@alexfertel alexfertel self-assigned this Apr 3, 2024
@alexfertel
Copy link
Author

A spike trying to get this to work resulted in these changes. In the end, it is impossible to set msg::sender right now since it is a global CachedOption private to the SDK, so we can't access it.

@0xNeshi
Copy link
Collaborator

0xNeshi commented Sep 17, 2024

Maybe a wrapper around msg::sender similar to Solidity's Context would alleviate the issue?
If there were a pub trait IContext that was implemented for the Context contract (that other contracts inherit), then the trait can be mocked in tests (e.g. using mockall)

@qalisander qalisander changed the title Allow setting msg::sender in unit tests [Feature]: Allow setting msg::sender in motsu unit tests Oct 3, 2024
@qalisander qalisander changed the title [Feature]: Allow setting msg::sender in motsu unit tests [Feature]: Allow setting msg::sender in unit tests Oct 3, 2024
@ggonzalez94 ggonzalez94 transferred this issue from OpenZeppelin/rust-contracts-stylus Dec 17, 2024
@github-project-automation github-project-automation bot moved this from Blocked to Done in Rust Contracts Stylus Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants