Expand description
§Partner Chains Mocked Data Sources
This crate provides mocked implementations of all data source interfaces used
by the Partner Chain toolkit’s components, that can be wired into a Substrate
node to avoid having access to a real data source like the Db-Sync data sources
provided by partner_chain_db_sync_data_sources
crate.
§Usage
Important: The mock data sources completely replace any interaction of the Partner Chain with its Cardano main chain, making them suitable only for local development and early exploration. They should not be used in production of public testnets.
The mock data sources defined in this crate are meant to make it possible to run a Partner Chain node with as little additional work as possible. Because of that, most of them return either empty or constant data. The important exception is the AuthoritySelectionDataSourceMock which can be fully configured with epoch data. See each data source’s documentation to see if and how it can be configured.
The mock data sources should be created as part of the node code, like so:
use partner_chains_mock_data_sources::*;
use std::error::Error;
use std::sync::Arc;
pub fn create_mock_data_sources()
-> std::result::Result<(), Box<dyn Error + Send + Sync + 'static>> {
/// The block data source is reused by other data sources
let block = Arc::new(BlockDataSourceMock::new_from_env()?);
let mc_hash = Arc::new(McHashDataSourceMock::new(block.clone()));
let sidechain_rpc = Arc::new(SidechainRpcDataSourceMock::new(block));
let authority_selection = Arc::new(AuthoritySelectionDataSourceMock::new_from_env()?);
let native_token = Arc::new(NativeTokenDataSourceMock::new());
let block_participation = Arc::new(StakeDistributionDataSourceMock::new());
let governed_map = Arc::new(GovernedMapDataSourceMock::default());
Ok(())
}
After that they can be passed as dependencies to other Partner Chains toolkit components.
Structs§
- Authority
Selection Data Source Mock - Mock authority selection data source that serves registration data in a round-robin fashion
- Block
Data Source Mock - Mock block data data source, for internal use by other mock data sources
- Governed
MapData Source Mock - Mocked governed map data source that serves constant data
- McHash
Data Source Mock - Mock MC reference hash data source
- Mock
Epoch Candidates - Mock authority selection data for a single epoch
- Mock
Registrations Config - Configuration of the mocked authority selection data source
- Native
Token Data Source Mock - Mock native token data source that serves constant data
- Sidechain
RpcData Source Mock - Mock sidechain RPC data source returning constant data
- Stake
Distribution Data Source Mock - Mocked stake distribution data source that returns empty data