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

Add a public export for web3::helpers::TestTranport #134

Open
adklempner opened this issue Jun 29, 2018 · 4 comments
Open

Add a public export for web3::helpers::TestTranport #134

adklempner opened this issue Jun 29, 2018 · 4 comments
Labels

Comments

@adklempner
Copy link

I'd like to use the mocked TestTransport struct for testing a crate that depends on rust-web3.

Is there already a way of doing this? If not, what would be the best way to export it? Would be happy to open a PR for this.

@tomusdrw
Copy link
Owner

tomusdrw commented Jul 2, 2018

Sounds good to me, should probably be feature-gated like other transports.

@creese
Copy link
Contributor

creese commented Nov 5, 2020

I tried use web3::helpers::tests::TestTransport but I'm getting an unresolved import error. Why doesn't this work?

@tomusdrw
Copy link
Owner

tomusdrw commented Nov 5, 2020

The entire tests module is gated with #[cfg(test)] which means it's only compiled when tests for web3 crate are running (the tests running on your crate that depends on web3 does not inlcude this code).

My earlier suggestion was to extract TestTransport to web3::transports module and expose it from there, adding a Cargo feature for the test transport (just like we have http and ws transports now.

@marmistrz
Copy link
Contributor

What do you think about switching Rc<RefCell<_>> to Arc<RwLock<_>> so that TestTransport implements Sync + Send?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants