mithril_common/era/adapters/
bootstrap.rs1use async_trait::async_trait;
2
3use crate::entities::Epoch;
4use crate::era::{EraMarker, EraReaderAdapter, SupportedEra};
5use crate::StdResult;
6
7pub struct BootstrapAdapter;
11
12#[async_trait]
13impl EraReaderAdapter for BootstrapAdapter {
14 async fn read(&self) -> StdResult<Vec<EraMarker>> {
15 Ok(vec![EraMarker::new(
16 &SupportedEra::eras().first().unwrap().to_string(),
17 Some(Epoch(0)),
18 )])
19 }
20}
21
22#[cfg(test)]
23mod tests {
24 use crate::era::SupportedEra;
25
26 use super::*;
27
28 #[tokio::test]
29 async fn bootstrap_adapter() {
30 let adapter = BootstrapAdapter;
31
32 assert_eq!(
33 vec![EraMarker::new(
34 &SupportedEra::dummy().to_string(),
35 Some(Epoch(0))
36 )],
37 adapter
38 .read()
39 .await
40 .expect("bootstrap adapter shall never fail")
41 );
42 }
43}