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

create utilities for writing unit tests with a Mock Provider (no rpc eth node required) #42

Closed
wants to merge 7 commits into from

Conversation

insipx
Copy link
Contributor

@insipx insipx commented Jan 25, 2024

No description provided.

Copy link
Contributor

@jac18281828 jac18281828 left a comment

Choose a reason for hiding this comment

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

What do you think of continuing to provide 'smoke' test coverage from the anvil integration test, while implementing the blanket api coverage in both mock and unit form?


use crate::types::GatewayContext;

pub async fn create_mock_context() -> (GatewayContext<Provider<MockProvider>>, MockProvider) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is really cool. Thanks for leading the way on this!

@insipx
Copy link
Contributor Author

insipx commented Jan 25, 2024

What do you think of continuing to provide 'smoke' test coverage from the anvil integration test, while implementing the blanket api coverage in both mock and unit form?

yup! I think think the coverage we get from integration tests is super valuable, but having the ability to test smaller units of code w/o worrying about the network is v. nice for quick testing

I'm still experimenting with this a bit, because it requires pushing a bunch of requirements that the ethers library expects (i.e why this will require some boilerplate for generic transactions to the registry), but it will result in an easier time writing tests for our rpcs.

@insipx
Copy link
Contributor Author

insipx commented Jan 30, 2024

Going to put this on hold while I work on #20. Right now, you can push responses to the mock provider, but I don't think it's very useful, because all the responses have to be carefully curated to match the contract you're calling. In the interest of time and not rewriting the results of contract calls, I want to finish #20 and maybe revist later

it would be nice if we could find a library that can call a solidity contract w/ a mock state, without a node -- not sure if this exists

i.e it would be worth thinking through a design on this that is more flexible

@insipx insipx added the on-hold label Jan 30, 2024
@insipx insipx closed this Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants