From acd39cbc6c7c11b476e274cf83b1a3b96ad4e7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Mon, 11 Oct 2021 19:50:12 +0200 Subject: [PATCH] sc-offchain: Fix flaky http tests (#10000) --- substrate/client/offchain/src/api/http.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/substrate/client/offchain/src/api/http.rs b/substrate/client/offchain/src/api/http.rs index ce9fb298d1..31f7d60e34 100644 --- a/substrate/client/offchain/src/api/http.rs +++ b/substrate/client/offchain/src/api/http.rs @@ -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| async move { + // Wait until the complete request was received and processed, + // otherwise the tests are flaky. + let _ = req.into_body().collect::>().await; + Ok::<_, Infallible>(hyper::Response::new(hyper::Body::from( "Hello World!", )))