Latest hyper-rustls, remove async-recursion

I didn't remove async-recursion when I updated the repo to 1.77 as I forgot we
used it in the tests. I still had to add some Box::pins, which may have been a
valid option, on the prior Rust version, yet at least resolves everything now.

Also updates everything which doesn't introduce further depends.
This commit is contained in:
Luke Parker 2024-03-27 00:17:04 -04:00
parent 63521f6a96
commit 93be7a3067
No known key found for this signature in database
6 changed files with 233 additions and 241 deletions

371
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -23,7 +23,7 @@ hyper-util = { version = "0.1", default-features = false, features = ["http1", "
http-body-util = { version = "0.1", default-features = false } http-body-util = { version = "0.1", default-features = false }
tokio = { version = "1", default-features = false } tokio = { version = "1", default-features = false }
hyper-rustls = { version = "0.26", default-features = false, features = ["http1", "ring", "rustls-native-certs", "native-tokio"], optional = true } hyper-rustls = { version = "0.27", default-features = false, features = ["http1", "ring", "rustls-native-certs", "native-tokio"], optional = true }
zeroize = { version = "1", optional = true } zeroize = { version = "1", optional = true }
base64ct = { version = "1", features = ["alloc"], optional = true } base64ct = { version = "1", features = ["alloc"], optional = true }

View file

@ -20,7 +20,6 @@ workspace = true
hex = "0.4" hex = "0.4"
async-trait = "0.1" async-trait = "0.1"
async-recursion = "1"
zeroize = { version = "1", default-features = false } zeroize = { version = "1", default-features = false }
rand_core = { version = "0.6", default-features = false } rand_core = { version = "0.6", default-features = false }

View file

@ -135,7 +135,6 @@ pub(crate) async fn new_test(test_body: impl TestBody) {
*OUTER_OPS.get_or_init(|| Mutex::new(None)).lock().await = None; *OUTER_OPS.get_or_init(|| Mutex::new(None)).lock().await = None;
// Spawns a coordinator, if one has yet to be spawned, or else runs the test. // Spawns a coordinator, if one has yet to be spawned, or else runs the test.
#[async_recursion::async_recursion]
async fn spawn_coordinator_or_run_test(inner_ops: DockerOperations) { async fn spawn_coordinator_or_run_test(inner_ops: DockerOperations) {
// If the outer operations have yet to be set, these *are* the outer operations // If the outer operations have yet to be set, these *are* the outer operations
let outer_ops = OUTER_OPS.get().unwrap(); let outer_ops = OUTER_OPS.get().unwrap();
@ -178,7 +177,10 @@ pub(crate) async fn new_test(test_body: impl TestBody) {
test.provide_container(composition); test.provide_container(composition);
drop(context_lock); drop(context_lock);
test.run_async(spawn_coordinator_or_run_test).await; fn recurse(ops: DockerOperations) -> core::pin::Pin<Box<impl Send + Future<Output = ()>>> {
Box::pin(spawn_coordinator_or_run_test(ops))
}
test.run_async(recurse).await;
} else { } else {
let outer_ops = outer_ops.lock().await.take().unwrap(); let outer_ops = outer_ops.lock().await.take().unwrap();

View file

@ -20,7 +20,6 @@ workspace = true
hex = "0.4" hex = "0.4"
async-trait = "0.1" async-trait = "0.1"
async-recursion = "1"
zeroize = { version = "1", default-features = false } zeroize = { version = "1", default-features = false }
rand_core = { version = "0.6", default-features = false } rand_core = { version = "0.6", default-features = false }

View file

@ -161,54 +161,57 @@ pub(crate) async fn new_test(test_body: impl TestBody) {
*OUTER_OPS.get_or_init(|| Mutex::new(None)).lock().await = None; *OUTER_OPS.get_or_init(|| Mutex::new(None)).lock().await = None;
// Spawns a coordinator, if one has yet to be spawned, or else runs the test. // Spawns a coordinator, if one has yet to be spawned, or else runs the test.
#[async_recursion::async_recursion] pub(crate) fn spawn_coordinator_or_run_test(
async fn spawn_coordinator_or_run_test(inner_ops: DockerOperations) { inner_ops: DockerOperations,
// If the outer operations have yet to be set, these *are* the outer operations ) -> core::pin::Pin<Box<impl Send + Future<Output = ()>>> {
let outer_ops = OUTER_OPS.get().unwrap(); Box::pin(async {
if outer_ops.lock().await.is_none() { // If the outer operations have yet to be set, these *are* the outer operations
*outer_ops.lock().await = Some(inner_ops); let outer_ops = OUTER_OPS.get().unwrap();
} if outer_ops.lock().await.is_none() {
*outer_ops.lock().await = Some(inner_ops);
}
let context_lock = CONTEXT.get().unwrap().lock().await; let context_lock = CONTEXT.get().unwrap().lock().await;
let Context { pending_coordinator_compositions, handles, test_body } = let Context { pending_coordinator_compositions, handles, test_body } =
context_lock.as_ref().unwrap(); context_lock.as_ref().unwrap();
// Check if there is a coordinator left // Check if there is a coordinator left
let maybe_coordinator = { let maybe_coordinator = {
let mut remaining = pending_coordinator_compositions.lock().await; let mut remaining = pending_coordinator_compositions.lock().await;
let maybe_coordinator = if !remaining.is_empty() { let maybe_coordinator = if !remaining.is_empty() {
let handles = handles[handles.len() - remaining.len()].clone(); let handles = handles[handles.len() - remaining.len()].clone();
let composition = remaining.remove(0); let composition = remaining.remove(0);
Some((composition, handles)) Some((composition, handles))
} else {
None
};
drop(remaining);
maybe_coordinator
};
if let Some((mut composition, handles)) = maybe_coordinator {
let network = {
let outer_ops = outer_ops.lock().await;
let outer_ops = outer_ops.as_ref().unwrap();
// Spawn it by building another DockerTest which recursively calls this function
// TODO: Spawn this outside of DockerTest so we can remove the recursion
let serai_container = outer_ops.handle(&handles.serai);
composition.modify_env("SERAI_HOSTNAME", serai_container.ip());
let message_queue_container = outer_ops.handle(&handles.message_queue);
composition.modify_env("MESSAGE_QUEUE_RPC", message_queue_container.ip());
format!("container:{}", serai_container.name())
};
let mut test = DockerTest::new().with_network(dockertest::Network::External(network));
test.provide_container(composition);
drop(context_lock);
test.run_async(spawn_coordinator_or_run_test).await;
} else { } else {
None let outer_ops = outer_ops.lock().await.take().unwrap();
}; test_body.body(outer_ops, handles.clone()).await;
drop(remaining); }
maybe_coordinator })
};
if let Some((mut composition, handles)) = maybe_coordinator {
let network = {
let outer_ops = outer_ops.lock().await;
let outer_ops = outer_ops.as_ref().unwrap();
// Spawn it by building another DockerTest which recursively calls this function
// TODO: Spawn this outside of DockerTest so we can remove the recursion
let serai_container = outer_ops.handle(&handles.serai);
composition.modify_env("SERAI_HOSTNAME", serai_container.ip());
let message_queue_container = outer_ops.handle(&handles.message_queue);
composition.modify_env("MESSAGE_QUEUE_RPC", message_queue_container.ip());
format!("container:{}", serai_container.name())
};
let mut test = DockerTest::new().with_network(dockertest::Network::External(network));
test.provide_container(composition);
drop(context_lock);
test.run_async(spawn_coordinator_or_run_test).await;
} else {
let outer_ops = outer_ops.lock().await.take().unwrap();
test_body.body(outer_ops, handles.clone()).await;
}
} }
test.run_async(spawn_coordinator_or_run_test).await; test.run_async(spawn_coordinator_or_run_test).await;