Use the lowest zstd compression level during tests

Antonio Scandurra and Nathan Sobo created

Co-Authored-By: Nathan Sobo <nathan@zed.dev>

Change summary

crates/rpc/src/proto.rs  | 9 ++++++++-
crates/server/Cargo.toml | 5 ++---
2 files changed, 10 insertions(+), 4 deletions(-)

Detailed changes

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(())
     }

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"] }