diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5351b88..faf08ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: run: cargo test --workspace --all-targets test-shuttle: - needs: [check, test] + needs: [check] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -53,7 +53,7 @@ jobs: run: cargo test -p todc-mem --features shuttle --test snapshot --release test-turmoil: - needs: [check, test] + needs: [check] runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/todc-mem/src/register/mutex.rs b/todc-mem/src/register/mutex.rs index b135ef9..ae805de 100644 --- a/todc-mem/src/register/mutex.rs +++ b/todc-mem/src/register/mutex.rs @@ -136,14 +136,14 @@ mod tests { #[test] fn read() { let register: MutexRegister = MutexRegister::new(); - assert_eq!(false, register.read()); + assert!(!register.read()); } #[test] fn write() { let register = MutexRegister::new(); register.write(true); - assert_eq!(true, register.read()); + assert!(register.read()); } } diff --git a/todc-mem/src/snapshot/aad_plus_93/bounded.rs b/todc-mem/src/snapshot/aad_plus_93/bounded.rs index 29bea0e..e06c681 100644 --- a/todc-mem/src/snapshot/aad_plus_93/bounded.rs +++ b/todc-mem/src/snapshot/aad_plus_93/bounded.rs @@ -322,13 +322,14 @@ mod tests { #[test] fn encodes_to_u64_correctly() { - let mut contents: BoundedAtomicContents<6> = BoundedAtomicContents::default(); - contents.value = 0b00100100; - contents.view = [ - 0b10011111, 0b10001111, 0b10000111, 0b10000011, 0b10000001, 0b10000000, - ]; - contents.handshakes = [true, false, true, false, true, false]; - contents.toggle = true; + let contents: BoundedAtomicContents<6> = BoundedAtomicContents::<6> { + value: 0b00100100, + view: [ + 0b10011111, 0b10001111, 0b10000111, 0b10000011, 0b10000001, 0b10000000, + ], + handshakes: [true, false, true, false, true, false], + toggle: true, + }; let actual: u64 = contents.into(); let expected: u64 = 0b10010101_10000000_10000001_10000011_10000111_10001111_10011111_00100100; @@ -343,7 +344,7 @@ mod tests { handshakes: [true, false, false, false, false, true], toggle: false, }; - let encoding: u64 = contents.clone().into(); + let encoding: u64 = contents.into(); assert_eq!(contents, BoundedAtomicContents::from(encoding)); } } diff --git a/todc-mem/src/snapshot/aad_plus_93/unbounded.rs b/todc-mem/src/snapshot/aad_plus_93/unbounded.rs index 0010dfe..f9b55d3 100644 --- a/todc-mem/src/snapshot/aad_plus_93/unbounded.rs +++ b/todc-mem/src/snapshot/aad_plus_93/unbounded.rs @@ -280,7 +280,7 @@ mod tests { view: [1, 2], sequence: 10_000, }; - let encoding: u64 = contents.clone().into(); + let encoding: u64 = contents.into(); assert_eq!(contents, UnboundedAtomicContents::from(encoding)); } @@ -291,7 +291,7 @@ mod tests { view: [1, 2, 3], sequence: 10_000, }; - let encoding: u64 = contents.clone().into(); + let encoding: u64 = contents.into(); assert_eq!(contents, UnboundedAtomicContents::from(encoding)); } @@ -302,7 +302,7 @@ mod tests { view: [1, 2, 3, 4], sequence: 10_000, }; - let encoding: u64 = contents.clone().into(); + let encoding: u64 = contents.into(); assert_eq!(contents, UnboundedAtomicContents::from(encoding)); } @@ -313,7 +313,7 @@ mod tests { view: [1, 2, 3, 4, 5], sequence: 10_000, }; - let encoding: u64 = contents.clone().into(); + let encoding: u64 = contents.into(); assert_eq!(contents, UnboundedAtomicContents::from(encoding)); } } @@ -344,10 +344,11 @@ mod tests { #[test] fn encodes_if_two_processes() { - let mut contents: UnboundedAtomicContents<2> = UnboundedAtomicContents::default(); - contents.value = 0b00100100; - contents.view = [0b10000001, 0b10000000]; - contents.sequence = 0b11000000_11000000; + let contents: UnboundedAtomicContents<2> = UnboundedAtomicContents { + value: 0b00100100, + view: [0b10000001, 0b10000000], + sequence: 0b11000000_11000000, + }; let actual: u64 = contents.into(); let expected: u64 = 0b00000000_00000000_00000000_11000000_11000000_10000000_10000001_00100100; @@ -356,10 +357,11 @@ mod tests { #[test] fn encodes_if_three_processes() { - let mut contents: UnboundedAtomicContents<3> = UnboundedAtomicContents::default(); - contents.value = 0b00100100; - contents.view = [0b10000011, 0b10000001, 0b10000000]; - contents.sequence = 0b11000000_11000000; + let contents: UnboundedAtomicContents<3> = UnboundedAtomicContents { + value: 0b00100100, + view: [0b10000011, 0b10000001, 0b10000000], + sequence: 0b11000000_11000000, + }; let actual: u64 = contents.into(); let expected: u64 = 0b00000000_00000000_11000000_11000000_10000000_10000001_10000011_00100100; @@ -368,10 +370,11 @@ mod tests { #[test] fn encodes_if_four_processes() { - let mut contents: UnboundedAtomicContents<4> = UnboundedAtomicContents::default(); - contents.value = 0b00100100; - contents.view = [0b10000111, 0b10000011, 0b10000001, 0b10000000]; - contents.sequence = 0b11000000_11000000; + let contents: UnboundedAtomicContents<4> = UnboundedAtomicContents { + value: 0b00100100, + view: [0b10000111, 0b10000011, 0b10000001, 0b10000000], + sequence: 0b11000000_11000000, + }; let actual: u64 = contents.into(); let expected: u64 = 0b00000000_11000000_11000000_10000000_10000001_10000011_10000111_00100100; @@ -380,10 +383,11 @@ mod tests { #[test] fn encodes_if_five_processes() { - let mut contents: UnboundedAtomicContents<5> = UnboundedAtomicContents::default(); - contents.value = 0b00100100; - contents.view = [0b10001111, 0b10000111, 0b10000011, 0b10000001, 0b10000000]; - contents.sequence = 0b11000000_11000000; + let contents: UnboundedAtomicContents<5> = UnboundedAtomicContents { + value: 0b00100100, + view: [0b10001111, 0b10000111, 0b10000011, 0b10000001, 0b10000000], + sequence: 0b11000000_11000000, + }; let actual: u64 = contents.into(); let expected: u64 = 0b11000000_11000000_10000000_10000001_10000011_10000111_10001111_00100100; diff --git a/todc-net/src/abd_95.rs b/todc-net/src/abd_95.rs index 58d26e0..1971538 100644 --- a/todc-net/src/abd_95.rs +++ b/todc-net/src/abd_95.rs @@ -1,5 +1,5 @@ //! An atomic register based on the implementation by Attiya, Bar-Noy, and -//! Dolev [[ABD95]](https://dl.acm.org/doi/pdf/10.1145/200836.200869). +//! Dolev [\[ABD95\]](https://dl.acm.org/doi/pdf/10.1145/200836.200869). //! use bytes::Bytes; use std::fmt::Debug; use std::future::Future; diff --git a/todc-net/tests/abd_95/linearizability.rs b/todc-net/tests/abd_95/linearizability.rs index f22d9d4..01b87fc 100644 --- a/todc-net/tests/abd_95/linearizability.rs +++ b/todc-net/tests/abd_95/linearizability.rs @@ -181,12 +181,11 @@ fn random_reads_and_writes_with_random_failures() { // Simulate clients that submit requests to correct servers. assert!(NUM_CLIENTS <= correct_servers.len()); - for i in 0..NUM_CLIENTS { + for (i, register) in registers.into_iter().enumerate().take(NUM_CLIENTS) { let actions = actions.clone(); - let register = registers[i].clone(); let client_name = format!("client-{i}"); sim.client(client_name, async move { - let mut client = RecordingRegisterClient::::new(i, register, actions); + let mut client = RecordingRegisterClient::::new(i, register.clone(), actions); for _ in 0..NUM_OPERATIONS { client.perform_random_operation(WRITE_PROBABILITY).await?; } diff --git a/todc-net/tests/abd_95/write.rs b/todc-net/tests/abd_95/write.rs index b8d99f7..23dca31 100644 --- a/todc-net/tests/abd_95/write.rs +++ b/todc-net/tests/abd_95/write.rs @@ -1,16 +1,5 @@ use crate::simulate_servers; -#[test] -fn returns_nothing() { - let (mut sim, replicas) = simulate_servers(2); - sim.client("client", async move { - let value = replicas[0].write(123).await.unwrap(); - assert_eq!(value, ()); - Ok(()) - }); - sim.run().unwrap(); -} - #[test] fn sets_value_of_requested_replica() { let (mut sim, replicas) = simulate_servers(2); diff --git a/todc-utils/benches/wgl_checker.rs b/todc-utils/benches/wgl_checker.rs index 867ceaf..f7229fd 100644 --- a/todc-utils/benches/wgl_checker.rs +++ b/todc-utils/benches/wgl_checker.rs @@ -13,7 +13,7 @@ fn criterion_benchmark(c: &mut Criterion) { c.bench_function("WGLChecker - check linearizability of etcd log", |b| { b.iter_batched( || history.clone(), - |history| WGLChecker::::is_linearizable(history), + WGLChecker::::is_linearizable, BatchSize::SmallInput, ) }); diff --git a/todc-utils/src/specifications/snapshot.rs b/todc-utils/src/specifications/snapshot.rs index 062333a..4b82386 100644 --- a/todc-utils/src/specifications/snapshot.rs +++ b/todc-utils/src/specifications/snapshot.rs @@ -104,7 +104,7 @@ mod tests { #[test] fn scan_not_valid_if_differs_from_state() { - let mut new_state = Spec::init().clone(); + let mut new_state = Spec::init(); new_state[0] = 123; let (valid, _) = Spec::apply(&Scan(0, Some(new_state)), &Spec::init()); assert!(!valid);