Ensure that usernames, user ids, and client ids match in random collaboration test

This makes the logs easier to interpret
This commit is contained in:
Max Brunsfeld 2022-06-30 14:51:22 -07:00
parent 4ee8ee5a06
commit c5351a1276
3 changed files with 21 additions and 17 deletions

View file

@ -28,10 +28,7 @@ use std::{
convert::TryFrom,
fmt::Write as _,
future::Future,
sync::{
atomic::{AtomicUsize, Ordering},
Arc, Weak,
},
sync::{Arc, Weak},
time::{Duration, Instant},
};
use thiserror::Error;
@ -232,12 +229,8 @@ impl Drop for Subscription {
impl Client {
pub fn new(http: Arc<dyn HttpClient>) -> Arc<Self> {
lazy_static! {
static ref NEXT_CLIENT_ID: AtomicUsize = AtomicUsize::default();
}
Arc::new(Self {
id: NEXT_CLIENT_ID.fetch_add(1, Ordering::SeqCst),
id: 0,
peer: Peer::new(),
http,
state: Default::default(),
@ -257,6 +250,12 @@ impl Client {
self.http.clone()
}
#[cfg(any(test, feature = "test-support"))]
pub fn set_id(&mut self, id: usize) -> &Self {
self.id = id;
self
}
#[cfg(any(test, feature = "test-support"))]
pub fn tear_down(&self) {
let mut state = self.state.write();