Skip to content

Commit

Permalink
Clippy fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cobward committed Dec 5, 2024
1 parent 25feadb commit 2760962
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
7 changes: 3 additions & 4 deletions src/core/presentation_submission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub struct MatchingInputs<'a, T> {
pub by_descriptor: HashMap<&'a str, Vec<usize>>,
}

impl<'a, T> MatchingInputs<'a, T> {
impl<T> MatchingInputs<'_, T> {
/// Validate the inputs against the presentation definition requirements.
pub fn validate(
&self,
Expand All @@ -152,10 +152,9 @@ impl<'a, T> MatchingInputs<'a, T> {
// By default each input descriptor must have at least one
// associated input.
for d in definition.input_descriptors() {
if !self
if self
.by_descriptor
.get(d.id.as_str())
.is_some_and(|i| !i.is_empty())
.get(d.id.as_str()).is_none_or(|i| i.is_empty())
{
return Err(SubmissionValidationError::MissingRequiredInput(
d.id.clone(),
Expand Down
6 changes: 2 additions & 4 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,10 @@ fn test_input_descriptor_validation() -> Result<()> {

let presentation_definition: PresentationDefinition = value
.as_object_mut()
.map(|obj| {
.and_then(|obj| {
obj.remove("presentation_definition")
.map(serde_json::from_value)
})
.flatten()
.expect("failed to parse presentation definition")?;

let presentation_submission = include_str!(
Expand All @@ -199,11 +198,10 @@ fn test_input_descriptor_validation() -> Result<()> {

let presentation_submission: PresentationSubmission = value
.as_object()
.map(|obj| {
.and_then(|obj| {
obj.get("presentation_submission")
.map(|v| serde_json::from_value(v.clone()))
})
.flatten()
.expect("failed to parse presentation submission")?;

// let descriptor_map = presentation_submission.descriptor_map();
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ async fn w3c_vc_did_client_direct_post() {
)
.set_name("DID Key Identity Verification".into())
.set_purpose("Check whether your identity key has been verified.".into())
.set_format((|| {
.set_format({
let mut map = ClaimFormatMap::new();
map.insert(
ClaimFormatDesignation::JwtVcJson,
ClaimFormatPayload::Alg(vec![Algorithm::ES256.to_string()]),
);
map
})()),
}),
);

let client_metadata = UntypedObject::default();
Expand Down
2 changes: 1 addition & 1 deletion tests/jwt_vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub async fn create_test_verifiable_presentation() -> Result<AnyJsonPresentation
.push(serde_json::from_value(json_credential)?);
vp.holder = Some(holder_did.into());
vp.id = UriBuf::new(
format!("urn:uuid:{}", Uuid::new_v4().to_string())
format!("urn:uuid:{}", Uuid::new_v4())
.as_bytes()
.to_vec(),
)
Expand Down

0 comments on commit 2760962

Please sign in to comment.