Skip to content

Commit

Permalink
refactor: ♻️ Refactor test code for readability.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jisu-Woniu committed Nov 23, 2023
1 parent 34e9fa9 commit ff638e3
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src-tauri/crypto/src/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ pub async fn sign_file_with_key(
#[cfg(test)]
mod tests {

use std::io::{self, BufReader};

use pgp::packet::{self, PacketParser};
use pgp::{
errors::Error as PgpError,
packet::{self, Packet, PacketParser},
};
use temp_dir::TempDir;
use tokio::fs::{self, read};

Expand Down Expand Up @@ -136,15 +137,16 @@ mod tests {
dbg!(&sig_data);
let packet = PacketParser::new(sig_data.as_slice())
.next()
.unwrap_or(Err(pgp::errors::Error::MissingPackets))?;
let signature = match packet {
packet::Packet::Signature(s) => Ok(s),
_ => Err(pgp::errors::Error::InvalidInput),
};
.ok_or(PgpError::MissingPackets)??;
let signature = if let Packet::Signature(s) = packet {
Ok(s)
} else {
Err(PgpError::InvalidInput)
}?;

dbg!(&signature);

let verified = verify(data, &public_key, &signature?).is_ok();
let verified = verify(data, &public_key, &signature).is_ok();

dbg!(verified);

Expand Down

0 comments on commit ff638e3

Please sign in to comment.