rust-web3
rust-web3 copied to clipboard
Add a public export for web3::helpers::TestTranport
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.
Sounds good to me, should probably be feature-gated like other transports.
I tried use web3::helpers::tests::TestTransport
but I'm getting an unresolved import error. Why doesn't this work?
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.
What do you think about switching Rc<RefCell<_>>
to Arc<RwLock<_>>
so that TestTransport
implements Sync + Send
?