Skip to content

Commit bb17f9f

Browse files
committed
Merge branch 'main' into fix/duplicate-client-messages
2 parents 5da772f + 8808870 commit bb17f9f

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

.github/workflows/rust-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
run: cargo fmt -- --check
2525

2626
- name: Cargo clippy
27-
run: cargo clippy --all --all-features -- -Dwarnings
27+
run: cargo clippy --all-targets --all-features --workspace -- -Dwarnings
2828

2929
- name: Run unit tests
3030
run: ./scripts/unit_test.sh

src/gateway-state/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,6 @@ mod tests {
399399

400400
{
401401
let gateway_state = gateway_state.clone();
402-
let canister_id = canister_id.clone();
403402
thread::spawn(move || loop {
404403
gateway_state.remove_canister_if_empty(canister_id);
405404
});
@@ -461,7 +460,6 @@ mod tests {
461460

462461
{
463462
let gateway_state = gateway_state.clone();
464-
let canister_id = canister_id.clone();
465463
thread::spawn(move || {
466464
for i in 0.. {
467465
let client_key = ClientKey::new(Principal::anonymous(), i);
@@ -516,7 +514,6 @@ mod tests {
516514

517515
{
518516
let gateway_state = gateway_state.clone();
519-
let canister_id = canister_id.clone();
520517
thread::spawn(move || {
521518
for i in 0.. {
522519
let client_key = ClientKey::new(Principal::anonymous(), i);

src/ic-websocket-gateway/src/tests/canister_poller.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
// mockito::Server is behind a SYNC mutex so that only one test at the same time can access it
2+
// otherwise, as async tests are run on multiple threads, the mock response of one test might overwrite
3+
// the mock response of another, causing the test to fail
4+
// acquiring the mutex and the beginning of each test and dropping the guard only at the end,
5+
// ensures that only one test at the time can set the mock response
6+
// this enables running the tests without specifying each time "-- --test-threads=1"
7+
#[allow(clippy::await_holding_lock)]
18
#[cfg(test)]
29
mod test {
310
use candid::Principal;
@@ -86,14 +93,12 @@ mod test {
8693
}
8794

8895
lazy_static! {
89-
// mockito::Server is behind a SYNC mutex so that only one test at the same time can access it
90-
// otherwise, as async tests are run on multiple threads, the mock response of one test might overwrite
91-
// the mock response of another, causing the test to fail
92-
// acquiring the mutex and the beginning of each test and dropping the guard only at the end,
93-
// ensures that only one test at the time can set the mock response
94-
// this enables running the tests without specifying each time "-- --test-threads=1"
95-
static ref MOCK_SERVER: Arc<Mutex<mockito::Server>> =
96-
Arc::new(Mutex::new(mockito::Server::new_with_opts(mockito::ServerOpts { port: 51558, ..Default::default() })));
96+
static ref MOCK_SERVER: Arc<Mutex<mockito::Server>> = Arc::new(Mutex::new(
97+
mockito::Server::new_with_opts(mockito::ServerOpts {
98+
port: 51558,
99+
..Default::default()
100+
})
101+
));
97102
}
98103

99104
fn create_poller(
@@ -332,7 +337,7 @@ mod test {
332337
.mock("GET", path)
333338
.with_chunked_body(|w| {
334339
thread::sleep(Duration::from_millis(POLLING_TIMEOUT_MS + 10));
335-
w.write_all(&vec![])
340+
w.write_all(&[])
336341
})
337342
.expect(2)
338343
.create_async()

0 commit comments

Comments
 (0)