Skip to content

Commit

Permalink
Apply rustfmt (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Dec 27, 2024
1 parent 9cbdfa7 commit 36de3df
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 42 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ jobs:
- name: Cargo Test
run: cargo test --verbose --features "${{ matrix.features }}"

fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- run: cargo fmt --check

clippy:
name: Run Clippy
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion src/net/tcp/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,4 +430,4 @@ impl Drop for WriteHalf {
world.current_host_mut().tcp.close_stream_half(*self.pair);
})
}
}
}
4 changes: 2 additions & 2 deletions src/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,13 @@ impl UdpSocket {
Ok(())
}

/// Has no effect in turmoil. API parity with
/// Has no effect in turmoil. API parity with
/// https://docs.rs/tokio/latest/tokio/net/struct.UdpSocket.html#method.set_multicast_loop_v6
pub fn set_multicast_loop_v6(&self, _on: bool) -> Result<()> {
Ok(())
}

/// Has no effect in turmoil. API parity with
/// Has no effect in turmoil. API parity with
/// https://docs.rs/tokio/latest/tokio/net/struct.UdpSocket.html#method.join_multicast_v6
pub fn join_multicast_v6(&self, _multiaddr: &Ipv6Addr, _interface: u32) -> Result<()> {
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/rt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use futures::Future;
use tokio::runtime::Runtime;
use tokio::task::JoinHandle;
use tokio::task::LocalSet;
use tokio::time::{Duration, Instant, sleep};
use tokio::time::{sleep, Duration, Instant};

use super::Result;

Expand Down
52 changes: 14 additions & 38 deletions src/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use indexmap::IndexMap;
use tokio::time::Duration;
use tracing::Level;

use crate::{Config, for_pairs, LinksIter, Result, Rt, ToIpAddr, ToIpAddrs, TRACING_TARGET, World};
use crate::host::HostTimer;
use crate::{for_pairs, Config, LinksIter, Result, Rt, ToIpAddr, ToIpAddrs, World, TRACING_TARGET};

/// A handle for interacting with the simulation.
pub struct Sim<'a> {
Expand Down Expand Up @@ -430,17 +430,16 @@ impl<'a> Sim<'a> {
#[cfg(test)]
mod test {
use rand::Rng;
use std::future;
use std::{
net::{IpAddr, Ipv4Addr},
rc::Rc,
sync::{
Mutex,
Arc,
atomic::{AtomicU64, Ordering},
Arc, Mutex,
},
time::Duration,
};
use std::future;

use tokio::{
io::{AsyncReadExt, AsyncWriteExt},
Expand All @@ -450,9 +449,9 @@ mod test {

use crate::net::UdpSocket;
use crate::{
Builder, elapsed,
hold,
net::{TcpListener, TcpStream}, Result, Sim, sim_elapsed, World,
elapsed, hold,
net::{TcpListener, TcpStream},
sim_elapsed, Builder, Result, Sim, World,
};

#[test]
Expand Down Expand Up @@ -686,7 +685,6 @@ mod test {
Ok(())
}


struct Expectation {
expect_a_receive: bool,
expect_b_receive: bool,
Expand Down Expand Up @@ -848,41 +846,19 @@ mod test {
Ok(())
}

run_with_actions(&[
Action::PartitionOnewayAB,
])?;
run_with_actions(&[
Action::PartitionOnewayBA,
])?;
run_with_actions(&[Action::PartitionOnewayAB])?;
run_with_actions(&[Action::PartitionOnewayBA])?;
run_with_actions(&[Action::Partition, Action::RepairOnewayAB])?;
run_with_actions(&[Action::Partition, Action::RepairOnewayBA])?;
run_with_actions(&[Action::PartitionOnewayAB, Action::Repair])?;
run_with_actions(&[Action::PartitionOnewayBA, Action::Repair])?;
run_with_actions(&[Action::PartitionOnewayBA, Action::RepairOnewayAB])?;
run_with_actions(&[Action::PartitionOnewayAB, Action::PartitionOnewayBA])?;
run_with_actions(&[
Action::Partition,
Action::RepairOnewayAB,
])?;
run_with_actions(&[
Action::Partition,
Action::RepairOnewayBA,
])?;
run_with_actions(&[
Action::PartitionOnewayAB,
Action::Repair,
])?;
run_with_actions(&[
Action::PartitionOnewayBA,
Action::Repair,
])?;
run_with_actions(&[
Action::PartitionOnewayBA,
Action::RepairOnewayAB,
])?;
run_with_actions(&[
Action::PartitionOnewayAB,
Action::PartitionOnewayBA,
])?;
run_with_actions(&[
Action::Partition,
Action::RepairOnewayAB,
Action::RepairOnewayBA
])?;

Ok(())
}
Expand Down

0 comments on commit 36de3df

Please sign in to comment.