Skip to content

Commit

Permalink
implement BlockCache trait for MockBlockSource
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar-Pepper authored and str4d committed Oct 28, 2024
1 parent 07006b4 commit 4c83f30
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions zcash_client_backend/src/data_api/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -730,4 +730,34 @@ pub mod testing {
Ok(())
}
}

impl BlockCache for MockBlockSource {
async fn get_tip_height<WalletErrT>(
&self,
_range: Option<&ScanRange>,
) -> Result<Option<BlockHeight>, Error<WalletErrT, Self::Error>> {
Ok(None)
}

async fn read<WalletErrT>(
&self,
_range: &ScanRange,
) -> Result<Vec<CompactBlock>, Error<WalletErrT, Self::Error>> {
Ok(Vec::new())
}

async fn insert<WalletErrT>(
&self,
_compact_blocks: Vec<CompactBlock>,
) -> Result<(), Error<WalletErrT, Self::Error>> {
Ok(())
}

async fn delete<WalletErrT>(
&self,
_range: ScanRange,
) -> Result<(), Error<WalletErrT, Self::Error>> {
Ok(())
}
}
}

0 comments on commit 4c83f30

Please sign in to comment.