sc-offchain: Fix flaky http tests (#10000)

This commit is contained in:
Bastian Köcher
2021-10-11 19:50:12 +02:00
committed by GitHub
parent 991bc30148
commit acd39cbc6c
+6 -2
View File
@@ -700,7 +700,7 @@ mod tests {
use super::{http, SharedClient};
use crate::api::timestamp;
use core::convert::Infallible;
use futures::future;
use futures::{future, StreamExt};
use lazy_static::lazy_static;
use sp_core::offchain::{Duration, HttpError, HttpRequestId, HttpRequestStatus};
@@ -725,7 +725,11 @@ mod tests {
let server = hyper::Server::bind(&"127.0.0.1:0".parse().unwrap()).serve(
hyper::service::make_service_fn(|_| async move {
Ok::<_, Infallible>(hyper::service::service_fn(
move |_req| async move {
move |req: hyper::Request<hyper::Body>| async move {
// Wait until the complete request was received and processed,
// otherwise the tests are flaky.
let _ = req.into_body().collect::<Vec<_>>().await;
Ok::<_, Infallible>(hyper::Response::new(hyper::Body::from(
"Hello World!",
)))