From ebecb6dad42c302bbc0eba3a9500ef7cc858b55d Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 17 Feb 2022 15:16:51 +0100 Subject: [PATCH] Use the lowest zstd compression level during tests Co-Authored-By: Nathan Sobo --- crates/rpc/src/proto.rs | 9 ++++++++- crates/server/Cargo.toml | 5 ++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/rpc/src/proto.rs b/crates/rpc/src/proto.rs index 6352c466c9..8093f2551f 100644 --- a/crates/rpc/src/proto.rs +++ b/crates/rpc/src/proto.rs @@ -271,12 +271,19 @@ where { /// Write a given protobuf message to the stream. pub async fn write_message(&mut self, message: &Envelope) -> Result<(), WebSocketError> { + #[cfg(any(test, feature = "test-support"))] + const COMPRESSION_LEVEL: i32 = -7; + + #[cfg(not(any(test, feature = "test-support")))] + const COMPRESSION_LEVEL: i32 = 4; + self.encoding_buffer.resize(message.encoded_len(), 0); self.encoding_buffer.clear(); message .encode(&mut self.encoding_buffer) .map_err(|err| io::Error::from(err))?; - let buffer = zstd::stream::encode_all(self.encoding_buffer.as_slice(), 4).unwrap(); + let buffer = + zstd::stream::encode_all(self.encoding_buffer.as_slice(), COMPRESSION_LEVEL).unwrap(); self.stream.send(WebSocketMessage::Binary(buffer)).await?; Ok(()) } diff --git a/crates/server/Cargo.toml b/crates/server/Cargo.toml index a4357415da..38aeac8a6b 100644 --- a/crates/server/Cargo.toml +++ b/crates/server/Cargo.toml @@ -15,7 +15,6 @@ required-features = ["seed-support"] [dependencies] collections = { path = "../collections" } rpc = { path = "../rpc" } - anyhow = "1.0.40" async-std = { version = "1.8.0", features = ["attributes"] } async-trait = "0.1.50" @@ -57,12 +56,12 @@ features = ["runtime-async-std-rustls", "postgres", "time", "uuid"] [dev-dependencies] collections = { path = "../collections", features = ["test-support"] } -gpui = { path = "../gpui" } +gpui = { path = "../gpui", features = ["test-support"] } +rpc = { path = "../rpc", features = ["test-support"] } zed = { path = "../zed", features = ["test-support"] } ctor = "0.1" env_logger = "0.8" util = { path = "../util" } - lazy_static = "1.4" serde_json = { version = "1.0.64", features = ["preserve_order"] }