pub trait ImmutableDigester: Sync + Send {
// Required methods
fn compute_digest<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dirpath: &'life1 Path,
beacon: &'life2 CardanoDbBeacon,
) -> Pin<Box<dyn Future<Output = Result<String, ImmutableDigesterError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn compute_merkle_tree<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dirpath: &'life1 Path,
beacon: &'life2 CardanoDbBeacon,
) -> Pin<Box<dyn Future<Output = Result<MKTree<MKTreeStoreInMemory>, ImmutableDigesterError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}
Expand description
A digester than can compute the digest used for mithril signatures
If you want to mock it using mockall:
mod test {
use async_trait::async_trait;
use mithril_common::digesters::{ImmutableDigester, ImmutableDigesterError};
use mithril_common::entities::CardanoDbBeacon;
use mithril_common::crypto_helper::{MKTree, MKTreeStoreInMemory};
use anyhow::anyhow;
use mockall::mock;
use std::path::Path;
mock! {
pub ImmutableDigesterImpl { }
#[async_trait]
impl ImmutableDigester for ImmutableDigesterImpl {
async fn compute_digest(
&self,
dirpath: &Path,
beacon: &CardanoDbBeacon,
) -> Result<String, ImmutableDigesterError>;
async fn compute_merkle_tree(
&self,
dirpath: &Path,
beacon: &CardanoDbBeacon,
) -> Result<MKTree<MKTreeStoreInMemory>, ImmutableDigesterError>;
}
}
#[test]
fn test_mock() {
let mut mock = MockDigesterImpl::new();
mock.expect_compute_digest().return_once(|_, _| {
Err(ImmutableDigesterError::NotEnoughImmutable {
expected_number: 3,
found_number: None,
db_dir: PathBuff::new(),
})
});
mock.expect_compute_merkle_tree().return_once(|_, _| {
Err(ImmutableDigesterError::MerkleTreeComputationError(anyhow!("Error")))
});
}
}
Required Methods§
sourcefn compute_digest<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dirpath: &'life1 Path,
beacon: &'life2 CardanoDbBeacon,
) -> Pin<Box<dyn Future<Output = Result<String, ImmutableDigesterError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn compute_digest<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dirpath: &'life1 Path,
beacon: &'life2 CardanoDbBeacon,
) -> Pin<Box<dyn Future<Output = Result<String, ImmutableDigesterError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Compute the digest
sourcefn compute_merkle_tree<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dirpath: &'life1 Path,
beacon: &'life2 CardanoDbBeacon,
) -> Pin<Box<dyn Future<Output = Result<MKTree<MKTreeStoreInMemory>, ImmutableDigesterError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn compute_merkle_tree<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
dirpath: &'life1 Path,
beacon: &'life2 CardanoDbBeacon,
) -> Pin<Box<dyn Future<Output = Result<MKTree<MKTreeStoreInMemory>, ImmutableDigesterError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Compute the digests merkle tree