use crate::{Block, BlockForkPoint, ExecutorConfig};
use std::sync::Arc;
use subxt::config::substrate::H256;
use url::Url;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ChainType {
RelayChain,
Parachain {
para_id: u32,
},
}
pub struct BlockchainError;
pub struct MockBlockchain;
impl MockBlockchain {
#[allow(unused_variables)]
pub async fn fork(
endpoint: &Url,
cache_path: Option<&str>,
) -> Result<Arc<Self>, BlockchainError> {
Ok(Arc::new(Self))
}
#[allow(unused_variables)]
pub async fn fork_at(
endpoint: &Url,
cache_path: Option<&str>,
fork_point: Option<BlockForkPoint>,
) -> Result<Arc<Self>, BlockchainError> {
Ok(Arc::new(Self))
}
#[allow(unused_variables)]
pub async fn fork_with_config(
endpoint: &Url,
cache_path: Option<&str>,
fork_point: Option<BlockForkPoint>,
config: ExecutorConfig,
) -> Result<Arc<Self>, BlockchainError> {
Ok(Arc::new(Self))
}
pub fn chain_name(&self) -> &str {
""
}
pub fn chain_type(&self) -> &ChainType {
&ChainType::RelayChain
}
pub fn fork_point(&self) -> H256 {
H256::zero()
}
pub fn fork_point_number(&self) -> u32 {
0
}
pub async fn head(&self) -> Result<Block, BlockchainError> {
Err(BlockchainError)
}
pub async fn head_number(&self) -> u32 {
0
}
pub async fn head_hash(&self) -> H256 {
H256::zero()
}
#[allow(unused_variables)]
pub async fn build_block(&self, extrinsics: Vec<Vec<u8>>) -> Result<Block, BlockchainError> {
Err(BlockchainError)
}
pub async fn build_empty_block(&self) -> Result<Block, BlockchainError> {
Err(BlockchainError)
}
#[allow(unused_variables)]
pub async fn call(&self, method: &str, args: &[u8]) -> Result<Vec<u8>, BlockchainError> {
Ok(vec![])
}
#[allow(unused_variables)]
pub async fn storage(&self, key: &[u8]) -> Result<Option<Vec<u8>>, BlockchainError> {
Ok(None)
}
}