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

New mock_environment function with valid contract address #2215

Closed
wants to merge 6 commits into from

Conversation

chipshort
Copy link
Collaborator

@chipshort chipshort commented Aug 16, 2024

an attempt at #2211

Problem is that this requires massive refactoring when changing existing tests. The borrow checker bites you whenever you use mock_environment(&deps.api) inside a call where you also pass deps, so you need to create the env first and then pass it to the function.
mock_dependencies_with_balances and mock_dependencies_with_balance are also affected by the invalid address problem and got new variants here too.

@@ -89,6 +103,20 @@ pub fn mock_dependencies_with_balances(
}
}

/// Initializes the querier along with the mock_dependencies.
/// Sets all balances provided (you must explicitly set contract balance if desired).
pub fn mock_dependencies_with_balances_valid(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This name is more of a placeholder because I couldn't come up with a good one.
Any ideas?

@webmaster128
Copy link
Member

Problem is that this requires massive refactoring when changing existing tests. The borrow checker bites you whenever you use mock_environment(&deps.api) inside a call where you also pass deps, so you need to create the env first and then pass it to the function.

I see, not great.

How do you feel about #2217 as an 80/20 solution and recommend advanced users to have their own version of mock_env where needed?

@chipshort
Copy link
Collaborator Author

Closing here for now, since we'll postpone to 3.0

@chipshort chipshort closed this Aug 21, 2024
@webmaster128 webmaster128 deleted the co/mock-env branch August 21, 2024 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants