Remove non-determinism from `Peer` caused by using std's `HashMap`

Antonio Scandurra created

Change summary

Cargo.lock             |  1 +
crates/rpc/Cargo.toml  | 10 ++++++----
crates/rpc/src/peer.rs |  8 +++++---
3 files changed, 12 insertions(+), 7 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -4007,6 +4007,7 @@ dependencies = [
  "async-tungstenite",
  "base64 0.13.0",
  "clock",
+ "collections",
  "futures",
  "gpui",
  "log",

crates/rpc/Cargo.toml 🔗

@@ -9,9 +9,13 @@ path = "src/rpc.rs"
 doctest = false
 
 [features]
-test-support = ["gpui/test-support"]
+test-support = ["collections/test-support", "gpui/test-support"]
 
 [dependencies]
+clock = { path = "../clock" }
+collections = { path = "../collections" }
+gpui = { path = "../gpui", optional = true }
+util = { path = "../util" }
 anyhow = "1.0"
 async-lock = "2.4"
 async-tungstenite = "0.16"
@@ -26,14 +30,12 @@ rsa = "0.4"
 serde = { version = "1", features = ["derive"] }
 smol-timeout = "0.6"
 zstd = "0.9"
-clock = { path = "../clock" }
-gpui = { path = "../gpui", optional = true }
-util = { path = "../util" }
 
 [build-dependencies]
 prost-build = "0.8"
 
 [dev-dependencies]
+collections = { path = "../collections", features = ["test-support"] }
 gpui = { path = "../gpui", features = ["test-support"] }
 smol = "1.2.5"
 tempdir = "0.3.7"

crates/rpc/src/peer.rs 🔗

@@ -1,6 +1,9 @@
-use super::proto::{self, AnyTypedEnvelope, EnvelopedMessage, MessageStream, RequestMessage};
-use super::Connection;
+use super::{
+    proto::{self, AnyTypedEnvelope, EnvelopedMessage, MessageStream, RequestMessage},
+    Connection,
+};
 use anyhow::{anyhow, Context, Result};
+use collections::HashMap;
 use futures::{channel::oneshot, stream::BoxStream, FutureExt as _, StreamExt};
 use parking_lot::{Mutex, RwLock};
 use postage::{
@@ -10,7 +13,6 @@ use postage::{
 use smol_timeout::TimeoutExt as _;
 use std::sync::atomic::Ordering::SeqCst;
 use std::{
-    collections::HashMap,
     fmt,
     future::Future,
     marker::PhantomData,