mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-24 23:31:33 +00:00
Setup CircleCI build (#107)
* Add circleci config file * Try enable IPv6 * Make sure `test` uses machine executor * Add an integration_test step in parallel * Explicit docker runs for machine tests * Try make the integration test work * Hide Dockerfile in a subfolder * Fix the ping example hanging * Explicitely pass the port to the ping client
This commit is contained in:
@ -29,6 +29,7 @@ extern crate tokio_core;
|
||||
extern crate tokio_io;
|
||||
|
||||
use futures::Future;
|
||||
use futures::sync::oneshot;
|
||||
use std::env;
|
||||
use swarm::{UpgradeExt, Transport, DeniedConnectionUpgrade};
|
||||
use tcp::TcpConfig;
|
||||
@ -79,11 +80,13 @@ fn main() {
|
||||
});
|
||||
|
||||
// We now use the controller to dial to the address.
|
||||
let (tx, rx) = oneshot::channel();
|
||||
swarm_controller
|
||||
.dial_custom_handler(target_addr.parse().expect("invalid multiaddr"), ping::Ping,
|
||||
|(mut pinger, future)| {
|
||||
let ping = pinger.ping().map_err(|_| unreachable!()).inspect(|_| {
|
||||
println!("Received pong from the remote");
|
||||
let _ = tx.send(());
|
||||
});
|
||||
ping.select(future).map(|_| ()).map_err(|(e, _)| e)
|
||||
})
|
||||
@ -98,5 +101,5 @@ fn main() {
|
||||
// `swarm_future` is a future that contains all the behaviour that we want, but nothing has
|
||||
// actually started yet. Because we created the `TcpConfig` with tokio, we need to run the
|
||||
// future through the tokio core.
|
||||
core.run(swarm_future).unwrap();
|
||||
core.run(rx.select(swarm_future.map_err(|_| unreachable!())).map_err(|(e, _)| e).map(|_| ())).unwrap();
|
||||
}
|
||||
|
Reference in New Issue
Block a user