Skip to content

Commit

Permalink
Fix clippy and doc warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kaymanb committed Sep 17, 2023
1 parent 43e4749 commit 4792ac3
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 49 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions todc-mem/src/register/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ mod tests {
#[test]
fn read() {
let register: MutexRegister<bool> = 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());
}
}

Expand Down
17 changes: 9 additions & 8 deletions todc-mem/src/snapshot/aad_plus_93/bounded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}
}
Expand Down
44 changes: 24 additions & 20 deletions todc-mem/src/snapshot/aad_plus_93/unbounded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand All @@ -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));
}

Expand All @@ -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));
}

Expand All @@ -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));
}
}
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion todc-net/src/abd_95.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 2 additions & 3 deletions todc-net/tests/abd_95/linearizability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<u32>::new(i, register, actions);
let mut client = RecordingRegisterClient::<u32>::new(i, register.clone(), actions);
for _ in 0..NUM_OPERATIONS {
client.perform_random_operation(WRITE_PROBABILITY).await?;
}
Expand Down
11 changes: 0 additions & 11 deletions todc-net/tests/abd_95/write.rs
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
2 changes: 1 addition & 1 deletion todc-utils/benches/wgl_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<EtcdSpecification>::is_linearizable(history),
WGLChecker::<EtcdSpecification>::is_linearizable,
BatchSize::SmallInput,
)
});
Expand Down
2 changes: 1 addition & 1 deletion todc-utils/src/specifications/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4792ac3

Please sign in to comment.