Skip to content

Commit

Permalink
Return NOT_FOUND if identity is missing (#130)
Browse files Browse the repository at this point in the history
* Return NOT_FOUND if identity is missing

* Fix test
  • Loading branch information
Dzejkop authored Oct 7, 2024
1 parent af8ffe6 commit cbb2798
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/tree/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ pub async fn inclusion_proof(
.inclusion_proof(req.identity_commitment, chain_id)
.await?;

Ok((StatusCode::OK, Json(inclusion_proof)))
match inclusion_proof {
Some(inclusion_proof) => {
Ok((StatusCode::OK, Json(Some(inclusion_proof))))
}
None => Ok((StatusCode::NOT_FOUND, Json(None))),
}
}

#[derive(Serialize, Deserialize, Debug)]
Expand Down
6 changes: 5 additions & 1 deletion tests/common/test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ impl TestClient {
.send()
.await?;

response.error_for_status_ref()?;
if response.status() == StatusCode::NOT_FOUND {
return Ok(None);
} else {
response.error_for_status_ref()?;
}

Ok(response.json().await?)
}
Expand Down

0 comments on commit cbb2798

Please sign in to comment.