From cbb27982cbff0916b5b285c22239bc14d6341b16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Tr=C4=85d?= Date: Mon, 7 Oct 2024 20:46:53 +0200 Subject: [PATCH] Return NOT_FOUND if identity is missing (#130) * Return NOT_FOUND if identity is missing * Fix test --- src/tree/service.rs | 7 ++++++- tests/common/test_client.rs | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/tree/service.rs b/src/tree/service.rs index efda39e4..61ccacc8 100644 --- a/src/tree/service.rs +++ b/src/tree/service.rs @@ -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)] diff --git a/tests/common/test_client.rs b/tests/common/test_client.rs index d0a70bc5..e6ea7ac1 100644 --- a/tests/common/test_client.rs +++ b/tests/common/test_client.rs @@ -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?) }