mirror of
https://github.com/status-im/libp2p-test-plans.git
synced 2025-02-17 09:16:41 +00:00
ping/rust: Add 0.50.0 as a release and fix deprecation warnings (#87)
This commit is contained in:
parent
31a128833d
commit
0ea1553b2c
@ -1,7 +1,11 @@
|
|||||||
[master]
|
[master]
|
||||||
BinaryName = 'testplan_0500'
|
BinaryName = 'testplan_0510'
|
||||||
|
|
||||||
[custom]
|
[custom]
|
||||||
|
BinaryName = 'testplan_0510'
|
||||||
|
|
||||||
|
[[groups]]
|
||||||
|
Id = '0.50.0'
|
||||||
BinaryName = 'testplan_0500'
|
BinaryName = 'testplan_0500'
|
||||||
|
|
||||||
[[groups]]
|
[[groups]]
|
||||||
|
703
ping/rust/Cargo.lock
generated
703
ping/rust/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -26,10 +26,11 @@ libp2pv0461 = { package = "libp2p", version = "0.46.1", default_features = false
|
|||||||
libp2pv0470 = { package = "libp2p", version = "0.47.0", default_features = false, features = ["websocket", "mplex", "yamux", "tcp-async-io", "ping", "noise", "dns-async-std"] }
|
libp2pv0470 = { package = "libp2p", version = "0.47.0", default_features = false, features = ["websocket", "mplex", "yamux", "tcp-async-io", "ping", "noise", "dns-async-std"] }
|
||||||
libp2pv0480 = { package = "libp2p", version = "0.48.0", default_features = false, features = ["websocket", "mplex", "yamux", "tcp-async-io", "ping", "noise", "dns-async-std", "rsa"] }
|
libp2pv0480 = { package = "libp2p", version = "0.48.0", default_features = false, features = ["websocket", "mplex", "yamux", "tcp-async-io", "ping", "noise", "dns-async-std", "rsa"] }
|
||||||
libp2pv0490 = { package = "libp2p", version = "0.49.0", features = ["websocket", "mplex", "yamux", "tcp", "async-std", "ping", "noise", "dns", "rsa"] }
|
libp2pv0490 = { package = "libp2p", version = "0.49.0", features = ["websocket", "mplex", "yamux", "tcp", "async-std", "ping", "noise", "dns", "rsa"] }
|
||||||
|
libp2pv0500 = { package = "libp2p", version = "0.50.0", features = ["websocket", "mplex", "yamux", "tcp", "async-std", "ping", "noise", "dns", "rsa", "macros"] }
|
||||||
|
|
||||||
# Next release
|
# Next release
|
||||||
[dependencies."libp2pv0500"]
|
[dependencies."libp2pv0510"]
|
||||||
package = "libp2p"
|
package = "libp2p"
|
||||||
git = "https://github.com/libp2p/rust-libp2p"
|
git = "https://github.com/libp2p/rust-libp2p"
|
||||||
rev = "368705a1465c4322948d14ee46d42475c472ca1e" # This should usually point to a commit on master.
|
rev = "be0b62a78fe9d72811b9eda742137cc8ddc4da35" # This should usually point to a commit on master.
|
||||||
features = ["websocket", "mplex", "yamux", "tcp", "ping", "noise", "dns", "async-std", "rsa", "macros"]
|
features = ["websocket", "mplex", "yamux", "tcp", "ping", "noise", "dns", "async-std", "rsa", "macros"]
|
||||||
|
@ -12,7 +12,7 @@ async fn main() -> Result<()> {
|
|||||||
let local_key = identity::Keypair::generate_ed25519();
|
let local_key = identity::Keypair::generate_ed25519();
|
||||||
let local_peer_id = PeerId::from(local_key.public());
|
let local_peer_id = PeerId::from(local_key.public());
|
||||||
|
|
||||||
let swarm = OrphanRuleWorkaround(Swarm::new(
|
let swarm = OrphanRuleWorkaround(Swarm::with_async_std_executor(
|
||||||
development_transport(local_key).await?,
|
development_transport(local_key).await?,
|
||||||
Behaviour {
|
Behaviour {
|
||||||
keep_alive: keep_alive::Behaviour,
|
keep_alive: keep_alive::Behaviour,
|
||||||
|
93
ping/rust/src/bin/testplan_0510.rs
Normal file
93
ping/rust/src/bin/testplan_0510.rs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
use anyhow::Result;
|
||||||
|
use async_trait::async_trait;
|
||||||
|
use futures::StreamExt;
|
||||||
|
use libp2pv0510::swarm::{keep_alive, NetworkBehaviour, SwarmEvent};
|
||||||
|
use libp2pv0510::*;
|
||||||
|
use std::collections::HashSet;
|
||||||
|
use std::time::Duration;
|
||||||
|
use testplan::{run_ping, PingSwarm};
|
||||||
|
|
||||||
|
#[async_std::main]
|
||||||
|
async fn main() -> Result<()> {
|
||||||
|
let local_key = identity::Keypair::generate_ed25519();
|
||||||
|
let local_peer_id = PeerId::from(local_key.public());
|
||||||
|
|
||||||
|
let swarm = OrphanRuleWorkaround(Swarm::with_async_std_executor(
|
||||||
|
development_transport(local_key).await?,
|
||||||
|
Behaviour {
|
||||||
|
keep_alive: keep_alive::Behaviour,
|
||||||
|
ping: ping::Behaviour::new(ping::Config::new().with_interval(Duration::from_secs(1))),
|
||||||
|
},
|
||||||
|
local_peer_id,
|
||||||
|
));
|
||||||
|
|
||||||
|
run_ping(swarm).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(NetworkBehaviour)]
|
||||||
|
#[behaviour(prelude = "libp2pv0510::swarm::derive_prelude")]
|
||||||
|
struct Behaviour {
|
||||||
|
keep_alive: keep_alive::Behaviour,
|
||||||
|
ping: ping::Behaviour,
|
||||||
|
}
|
||||||
|
|
||||||
|
struct OrphanRuleWorkaround(Swarm<Behaviour>);
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl PingSwarm for OrphanRuleWorkaround {
|
||||||
|
async fn listen_on(&mut self, address: &str) -> Result<()> {
|
||||||
|
let id = self.0.listen_on(address.parse()?)?;
|
||||||
|
|
||||||
|
loop {
|
||||||
|
if let Some(SwarmEvent::NewListenAddr { listener_id, .. }) = self.0.next().await {
|
||||||
|
if listener_id == id {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dial(&mut self, address: &str) -> Result<()> {
|
||||||
|
self.0.dial(address.parse::<Multiaddr>()?)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn await_connections(&mut self, number: usize) {
|
||||||
|
let mut connected = HashSet::with_capacity(number);
|
||||||
|
|
||||||
|
while connected.len() < number {
|
||||||
|
if let Some(SwarmEvent::ConnectionEstablished { peer_id, .. }) = self.0.next().await {
|
||||||
|
connected.insert(peer_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn await_pings(&mut self, number: usize) {
|
||||||
|
let mut received_pings = HashSet::with_capacity(number);
|
||||||
|
|
||||||
|
while received_pings.len() < number {
|
||||||
|
if let Some(SwarmEvent::Behaviour(BehaviourEvent::Ping(ping::Event {
|
||||||
|
peer,
|
||||||
|
result: Ok(ping::Success::Ping { .. }),
|
||||||
|
}))) = self.0.next().await
|
||||||
|
{
|
||||||
|
received_pings.insert(peer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn loop_on_next(&mut self) {
|
||||||
|
loop {
|
||||||
|
self.0.next().await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn local_peer_id(&self) -> String {
|
||||||
|
self.0.local_peer_id().to_string()
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user