pub trait TestHost:
Default
+ Debug
+ Sized {
type Block: TestBlock;
type ClientState: Into<AnyClientState> + Debug;
type BlockParams: Debug + Default;
type LightClientParams: Debug + Default;
// Required methods
fn history(&self) -> &Vec<Self::Block>;
fn push_block(&mut self, block: Self::Block);
fn generate_block(
&self,
commitment_root: Vec<u8>,
height: u64,
timestamp: Timestamp,
params: &Self::BlockParams,
) -> Self::Block;
fn generate_client_state(
&self,
latest_height: &Height,
params: &Self::LightClientParams,
) -> Self::ClientState;
// Provided methods
fn is_empty(&self) -> bool { ... }
fn latest_height(&self) -> Height { ... }
fn latest_block(&self) -> Self::Block { ... }
fn get_block(&self, target_height: &Height) -> Option<Self::Block> { ... }
fn commit_block(
&mut self,
commitment_root: Vec<u8>,
block_time: Duration,
params: &Self::BlockParams,
) { ... }
fn validate(&self) -> Result<(), String> { ... }
}Expand description
TestHost is a trait that defines the interface for a host blockchain.
Required Associated Types§
Sourcetype ClientState: Into<AnyClientState> + Debug
type ClientState: Into<AnyClientState> + Debug
The type of client state produced by the host.
Sourcetype BlockParams: Debug + Default
type BlockParams: Debug + Default
The type of block parameter to produce a block.
Sourcetype LightClientParams: Debug + Default
type LightClientParams: Debug + Default
The type of light client parameters to produce a light client state.
Required Methods§
Sourcefn push_block(&mut self, block: Self::Block)
fn push_block(&mut self, block: Self::Block)
Add a block to the host chain.
Sourcefn generate_block(
&self,
commitment_root: Vec<u8>,
height: u64,
timestamp: Timestamp,
params: &Self::BlockParams,
) -> Self::Block
fn generate_block( &self, commitment_root: Vec<u8>, height: u64, timestamp: Timestamp, params: &Self::BlockParams, ) -> Self::Block
Generate a block at the given height and timestamp, using the provided parameters.
Sourcefn generate_client_state(
&self,
latest_height: &Height,
params: &Self::LightClientParams,
) -> Self::ClientState
fn generate_client_state( &self, latest_height: &Height, params: &Self::LightClientParams, ) -> Self::ClientState
Generate a client state using the block at the given height and the provided parameters.
Provided Methods§
Sourcefn latest_height(&self) -> Height
fn latest_height(&self) -> Height
The latest height of the host chain.
Sourcefn latest_block(&self) -> Self::Block
fn latest_block(&self) -> Self::Block
The latest block of the host chain.
Sourcefn get_block(&self, target_height: &Height) -> Option<Self::Block>
fn get_block(&self, target_height: &Height) -> Option<Self::Block>
Get the block at the given height.
Sourcefn commit_block(
&mut self,
commitment_root: Vec<u8>,
block_time: Duration,
params: &Self::BlockParams,
)
fn commit_block( &mut self, commitment_root: Vec<u8>, block_time: Duration, params: &Self::BlockParams, )
Commit a block with commitment root to the blockchain, by extending the history of blocks.
fn validate(&self) -> Result<(), String>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.