-
Notifications
You must be signed in to change notification settings - Fork 998
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
transports/tcp: Unit test tokio feature #1820
Comments
Is there a simple way to make I was thinking of doing this: fn config() -> Result<Transport, io::Error> {
if cfg!(feature = "tokio") {
Ok(TokioTcpConfig::new())
} else if cfg!(feature = "async-std") {
Ok(TcpConfig::new())
} else {
io::Error("No Feature set.")
}
} But returns: I'm hoping the return object can be used in all tests. Then you wouldn't even really need to specify the feature for the unit tests. Thoughts? |
@ericjmiller first of all, thanks for looking into this. Cargo features have to be designed in an additive fashion. Say both the Tokio and the Async-std feature are enabled: In your example above, which transport should be returned? I would suggest a similar approach to the one we follow in our mdns tests. Here we use a macro to template the unit tests, invoking that macro with the Tokio mdns service when the tokio feature is enabled and invoking the macro with the async std mdns service when the async-std feature is enabled. With both enabled, the macro is invoked twice. What do you think @ericjmiller? |
Ah, okay. Thanks. regarding the mdns tests - that strategy makes sense to me. I'll shoot for that implementation. Stay tuned ... |
As of today
libp2p-tcp
is only tested with theasync-std
feature. Make the unit tests test both theasync-std
and thetokio
feature. Otherwise things like tokio-rs/tokio#3001 go unnoticed without testing thechat-tokio
example when upgrading (e.g. #1796).The text was updated successfully, but these errors were encountered: