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

feat: make runtime features optional in swarm-test #5551

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

hanabi1224
Copy link
Contributor

@hanabi1224 hanabi1224 commented Aug 12, 2024

Description

Sometimes a test uses custom swarm building logic and doesn't need fn new_ephemeral, and sometimes a test uses tokio runtime other than async-std.
This PR adds the tokio runtime support and makes both async-std and tokio runtimes optional behind features to make it more flexible.

Notes & open questions

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

@hanabi1224 hanabi1224 marked this pull request as ready for review August 12, 2024 00:45
Copy link
Member

@jxs jxs left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM overall, just left a couple of questions

where
Self: Sized,
{
use libp2p_core::{transport::MemoryTransport, upgrade::Version, Transport as _};
use libp2p_identity::Keypair;
Copy link
Member

Choose a reason for hiding this comment

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

same as the question above, why is the Keypair import moved from the top of the file to duplicated here and in the tokio case?

Copy link
Contributor Author

@hanabi1224 hanabi1224 Sep 13, 2024

Choose a reason for hiding this comment

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

When both async-std and tokio runtimes are disabled, top-level import of Keypair is unused and leads to clippy warnings

use libp2p_swarm::dial_opts::PeerCondition;
use libp2p_swarm::{self as swarm, dial_opts::DialOpts, NetworkBehaviour, Swarm, SwarmEvent};
use libp2p_yamux as yamux;
Copy link
Member

Choose a reason for hiding this comment

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

can we maintain these imports and renames?

Copy link
Contributor Author

@hanabi1224 hanabi1224 Sep 13, 2024

Choose a reason for hiding this comment

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

Same, these imports are only used in fn new_ephemeral and fn new_ephemeral_tokio. Disabling both runtime features would cause clippy warnings of used imports

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