From 4c83f309fa1f89c1bf673a19a52e8ba3c2f48b73 Mon Sep 17 00:00:00 2001 From: Oscar Pepper Date: Wed, 11 Sep 2024 16:56:48 +0100 Subject: [PATCH] implement BlockCache trait for MockBlockSource --- zcash_client_backend/src/data_api/chain.rs | 34 ++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/zcash_client_backend/src/data_api/chain.rs b/zcash_client_backend/src/data_api/chain.rs index 539b6c024..365f02e6d 100644 --- a/zcash_client_backend/src/data_api/chain.rs +++ b/zcash_client_backend/src/data_api/chain.rs @@ -709,9 +709,9 @@ pub mod testing { use std::convert::Infallible; use zcash_primitives::consensus::BlockHeight; - use crate::proto::compact_formats::CompactBlock; + use crate::{data_api::scanning::ScanRange, proto::compact_formats::CompactBlock}; - use super::{error::Error, BlockSource}; + use super::{error::Error, BlockCache, BlockSource}; pub struct MockBlockSource; @@ -730,4 +730,34 @@ pub mod testing { Ok(()) } } + + impl BlockCache for MockBlockSource { + async fn get_tip_height( + &self, + _range: Option<&ScanRange>, + ) -> Result, Error> { + Ok(None) + } + + async fn read( + &self, + _range: &ScanRange, + ) -> Result, Error> { + Ok(Vec::new()) + } + + async fn insert( + &self, + _compact_blocks: Vec, + ) -> Result<(), Error> { + Ok(()) + } + + async fn delete( + &self, + _range: ScanRange, + ) -> Result<(), Error> { + Ok(()) + } + } }