Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Check if storage is working when returning the response to a faucet healthcheck request. #1189

Merged
merged 2 commits into from
Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contracts/rust/src/bin/gen-vk-libraries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::{fs::OpenOptions, io::prelude::*, path::PathBuf};

// depth of the record merkle tree
const TREE_DEPTH: u8 = 24;
// list of supported tranaction types, each would result in a different verifying key
// list of supported transaction types, each would result in a different verifying key
const SUPPORTED_VKS: [(NoteType, u8, u8, u8); 7] = [
(NoteType::Transfer, 1, 2, TREE_DEPTH),
(NoteType::Transfer, 2, 2, TREE_DEPTH),
Expand Down
22 changes: 22 additions & 0 deletions faucet/src/faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,28 @@ pub struct HealthCheck {
/// normally, a response with status 503 and payload {"status":
/// "unavailable"} should be added.
async fn healthcheck(req: tide::Request<FaucetState>) -> Result<tide::Response, tide::Error> {
// Ensure we can write to storage.
let mut index = req.state().queue.index.lock().await;
let default_user_pub_key = UserPubKey::default();
let res = index.insert(default_user_pub_key.clone());
if res.is_err() {
tracing::error!(
"Insertion of dummy public key into faucet queue index failed. {:?}",
res
);
return Err(faucet_server_error(res.err().unwrap()));
}

let res = index.remove(&default_user_pub_key);
if res.is_err() {
tracing::error!(
"Removal of dummy public key from faucet queue index failed. {:?}",
res
);
return Err(faucet_server_error(res.err().unwrap()));
}

// Return healthcheck response
response(
&req,
&HealthCheck {
Expand Down