-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmock.rs
30 lines (26 loc) · 894 Bytes
/
mock.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use crate::SidechainRpcDataSource;
use derive_new::new;
use jsonrpsee::core::async_trait;
use sidechain_domain::{MainchainBlock, UtxoId};
use std::str::FromStr;
// The build.rs file of `substrate_test_runtime` is throwing an error. So a `Block` is being manually defined
pub type Block = sp_runtime::generic::Block<
sp_runtime::generic::Header<u32, sp_runtime::traits::BlakeTwo256>,
sp_runtime::OpaqueExtrinsic,
>;
#[allow(unused)]
pub(crate) fn mock_utxo_id() -> UtxoId {
UtxoId::from_str("0000000000000000000000000000000000000000000000000000000000000000#0").unwrap()
}
#[derive(new)]
pub struct SidechainRpcDataSourceMock {
latest_block: MainchainBlock,
}
#[async_trait]
impl SidechainRpcDataSource for SidechainRpcDataSourceMock {
async fn get_latest_block_info(
&self,
) -> Result<MainchainBlock, Box<dyn std::error::Error + Send + Sync>> {
Ok(self.latest_block.clone())
}
}