Skip to content

Commit

Permalink
Apply Clippy to tests and fix some lints (#1386)
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov authored Nov 12, 2023
1 parent 8b24dd9 commit ddbbc90
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ jobs:
- uses: RustCrypto/actions/cargo-cache@master
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.71.0
toolchain: 1.73.0
components: clippy
- run: cargo clippy --all --all-features -- -D warnings
- run: cargo clippy --all --all-features --tests -- -D warnings

rustfmt:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions elliptic-curve/src/hash2curve/hash2field/expand_msg/xmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ mod test {
}

impl TestVector {
#[allow(clippy::panic_in_result_fn)]
fn assert<HashT, L: ArrayLength<u8>>(
&self,
dst: &'static [u8],
Expand Down
10 changes: 3 additions & 7 deletions elliptic-curve/src/hash2curve/hash2field/expand_msg/xof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,7 @@ mod test {
use hex_literal::hex;
use sha3::Shake128;

fn assert_message<HashT>(
msg: &[u8],
domain: &Domain<'_, U32>,
len_in_bytes: u16,
bytes: &[u8],
) {
fn assert_message(msg: &[u8], domain: &Domain<'_, U32>, len_in_bytes: u16, bytes: &[u8]) {
let msg_len = msg.len();
assert_eq!(msg, &bytes[..msg_len]);

Expand All @@ -102,12 +97,13 @@ mod test {
}

impl TestVector {
#[allow(clippy::panic_in_result_fn)]
fn assert<HashT, L>(&self, dst: &'static [u8], domain: &Domain<'_, U32>) -> Result<()>
where
HashT: Default + ExtendableOutput + Update,
L: ArrayLength<u8>,
{
assert_message::<HashT>(self.msg, domain, L::to_u16(), self.msg_prime);
assert_message(self.msg, domain, L::to_u16(), self.msg_prime);

let mut expander =
ExpandMsgXof::<HashT>::expand_message(&[self.msg], &[dst], L::to_usize())?;
Expand Down
3 changes: 2 additions & 1 deletion elliptic-curve/src/jwk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ fn decode_base64url_fe<C: Curve>(s: &str) -> Result<FieldBytes<C>> {

#[cfg(test)]
mod tests {
#![allow(clippy::unwrap_used, clippy::panic)]
use super::*;

#[cfg(feature = "dev")]
Expand Down Expand Up @@ -656,7 +657,7 @@ mod tests {
let point = jwk.to_encoded_point::<MockCurve>().unwrap();
let (x, y) = match point.coordinates() {
Coordinates::Uncompressed { x, y } => (x, y),
other => panic!("unexpected coordinates: {:?}", other),
other => panic!("unexpected coordinates: {other:?}"),
};

assert_eq!(&decode_base64url_fe::<MockCurve>(&jwk.x).unwrap(), x);
Expand Down

0 comments on commit ddbbc90

Please sign in to comment.