You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all excuse me if I am missing something, this is a suggestion and a question as well.
libp2p-swarm-test are a great way to test libp2p protocols. However there is only a very specific implementations of
``fn new_ephemeral` variants, that create keys inside the function.
There is factory method which helps but still sometimes I want to create a Swarm with specified keys.
Motivation
I am using libp2p-swarm-test in my tests, specifically: fn new_ephemeral(behaviour_fn: impl FnOnce(libp2p_identity::Keypair) -> Self::NB) -> Self functions (I use tokio variant).
In lot of tests I actually need to create Swarm with existing key, and maybe specify some additional parameters to use in in creating a Swarm. I understand that the doc clearly says that the user of this functions should not rely upon the underlying parameters, but still the existing key use-case remains for me.
I solved this problem by creating my own Swarm factories with MemoryTransport but I was wondering if it would make sense to expand the existing ones in libp2p-swarm-test as well, as I really like the approach around libp2p-swarm-test.
Current Implementation
Current implementation supports most use-cases but does not support specifying already created key to a new_ephemeral function.
Are you planning to do it yourself in a pull request?
Yes
The text was updated successfully, but these errors were encountered:
but still sometimes I want to create a Swarm with specified keys
Can you expand a little bit on your use-case why you need to use specific keys in a test? If the keypair is used for other logic, is it not enough to read out the generated keypair in the behaviour_fn?
It's not a strong requirement, but I encountered a few cases where Behavior implementations needed a non-shared list of predefined keys. I managed to refactor most of them to avoid this need by updating the shared lists when creating new_ephemeral_tokio and using the key pair it generates (through behavior_fn). However, for some simulations, it was more convenient to pre-generate key pairs and initialize the test Swarm with them.
For example, when creating multiple ephemeral test swarms, some might require a fixed list of predefined key pairs. Currently, I need to use new_ephemeral_tokio to generate a key pair, extract it via behavior_fn, and then modify the relevant collections only after all n ephemerals are created.
In some tests, I ended up duplicating the logic from new_ephemeral_tokio but realized it could be useful to tweak some parameters (e.g., using pre-generated keys or adjusting the fallback protocol). This is especially relevant since the doc notes that callers shouldn't rely on specific underlying components, which may change in the future.
Again, this really isn't a strong requirement. I mainly opened the issue to propose the idea and get feedback on whether I'm using it as intended or if there's a better approach.
Description
First of all excuse me if I am missing something, this is a suggestion and a question as well.
libp2p-swarm-test
are a great way to test libp2p protocols. However there is only a very specific implementations of``fn new_ephemeral` variants, that create keys inside the function.
There is factory method which helps but still sometimes I want to create a Swarm with specified keys.
Motivation
I am using
libp2p-swarm-test
in my tests, specifically:fn new_ephemeral(behaviour_fn: impl FnOnce(libp2p_identity::Keypair) -> Self::NB) -> Self
functions (I use tokio variant).In lot of tests I actually need to create Swarm with existing key, and maybe specify some additional parameters to use in in creating a Swarm. I understand that the doc clearly says that the user of this functions should not rely upon the underlying parameters, but still the existing key use-case remains for me.
I solved this problem by creating my own Swarm factories with
MemoryTransport
but I was wondering if it would make sense to expand the existing ones inlibp2p-swarm-test
as well, as I really like the approach aroundlibp2p-swarm-test
.Current Implementation
Current implementation supports most use-cases but does not support specifying already created key to a
new_ephemeral
function.Are you planning to do it yourself in a pull request?
Yes
The text was updated successfully, but these errors were encountered: