mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 22:08:30 +00:00
Upgrade to tokio 0.3 (#1839)
## Description This PR updates Lighthouse to tokio 0.3. It includes a number of dependency updates and some structural changes as to how we create and spawn tasks. This also brings with it a number of various improvements: - Discv5 update - Libp2p update - Fix for recompilation issues - Improved UPnP port mapping handling - Futures dependency update - Log downgrade to traces for rejecting peers when we've reached our max Co-authored-by: blacktemplar <blacktemplar@a1.net>
This commit is contained in:
@@ -5,42 +5,47 @@ use reqwest::StatusCode;
|
||||
use std::net::Ipv4Addr;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::oneshot;
|
||||
use tokio_compat_02::FutureExt;
|
||||
use types::MainnetEthSpec;
|
||||
|
||||
type Context = http_metrics::Context<EphemeralHarnessType<MainnetEthSpec>>;
|
||||
|
||||
#[tokio::test(core_threads = 2)]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn returns_200_ok() {
|
||||
let log = null_logger().unwrap();
|
||||
async {
|
||||
let log = null_logger().unwrap();
|
||||
|
||||
let context = Arc::new(Context {
|
||||
config: Config {
|
||||
enabled: true,
|
||||
listen_addr: Ipv4Addr::new(127, 0, 0, 1),
|
||||
listen_port: 0,
|
||||
allow_origin: None,
|
||||
},
|
||||
chain: None,
|
||||
db_path: None,
|
||||
freezer_db_path: None,
|
||||
log,
|
||||
});
|
||||
let context = Arc::new(Context {
|
||||
config: Config {
|
||||
enabled: true,
|
||||
listen_addr: Ipv4Addr::new(127, 0, 0, 1),
|
||||
listen_port: 0,
|
||||
allow_origin: None,
|
||||
},
|
||||
chain: None,
|
||||
db_path: None,
|
||||
freezer_db_path: None,
|
||||
log,
|
||||
});
|
||||
|
||||
let ctx = context.clone();
|
||||
let (_shutdown_tx, shutdown_rx) = oneshot::channel::<()>();
|
||||
let server_shutdown = async {
|
||||
// It's not really interesting why this triggered, just that it happened.
|
||||
let _ = shutdown_rx.await;
|
||||
};
|
||||
let (listening_socket, server) = http_metrics::serve(ctx, server_shutdown).unwrap();
|
||||
let ctx = context.clone();
|
||||
let (_shutdown_tx, shutdown_rx) = oneshot::channel::<()>();
|
||||
let server_shutdown = async {
|
||||
// It's not really interesting why this triggered, just that it happened.
|
||||
let _ = shutdown_rx.await;
|
||||
};
|
||||
let (listening_socket, server) = http_metrics::serve(ctx, server_shutdown).unwrap();
|
||||
|
||||
tokio::spawn(async { server.await });
|
||||
tokio::spawn(async { server.await });
|
||||
|
||||
let url = format!(
|
||||
"http://{}:{}/metrics",
|
||||
listening_socket.ip(),
|
||||
listening_socket.port()
|
||||
);
|
||||
let url = format!(
|
||||
"http://{}:{}/metrics",
|
||||
listening_socket.ip(),
|
||||
listening_socket.port()
|
||||
);
|
||||
|
||||
assert_eq!(reqwest::get(&url).await.unwrap().status(), StatusCode::OK);
|
||||
assert_eq!(reqwest::get(&url).await.unwrap().status(), StatusCode::OK);
|
||||
}
|
||||
.compat()
|
||||
.await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user