Trait TestBlock

Source
pub trait TestBlock: Block<Header: TestHeader> {
    // Required methods
    fn body_mut(&mut self) -> &mut Self::Body;
    fn header_mut(&mut self) -> &mut Self::Header;
    fn set_header(&mut self, header: Self::Header);

    // Provided methods
    fn set_parent_hash(&mut self, hash: BlockHash) { ... }
    fn set_block_number(&mut self, number: BlockNumber) { ... }
    fn set_state_root(&mut self, state_root: B256) { ... }
    fn set_difficulty(&mut self, difficulty: U256) { ... }
}
Available on crate feature test-utils only.
Expand description

An extension trait for Blocks that allows for mutable access to the block’s internals.

This allows for modifying the block’s header and body for testing purposes.

Required Methods§

Source

fn body_mut(&mut self) -> &mut Self::Body

Returns mutable reference to block body.

Source

fn header_mut(&mut self) -> &mut Self::Header

Returns mutable reference to block header.

Source

fn set_header(&mut self, header: Self::Header)

Updates the block header.

Provided Methods§

Source

fn set_parent_hash(&mut self, hash: BlockHash)

Updates the parent block hash.

Source

fn set_block_number(&mut self, number: BlockNumber)

Updates the block number.

Source

fn set_state_root(&mut self, state_root: B256)

Updates the block state root.

Source

fn set_difficulty(&mut self, difficulty: U256)

Updates the block difficulty.

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.

Implementations on Foreign Types§

Source§

impl<T, H> TestBlock for Block<T, H>

Source§

fn body_mut(&mut self) -> &mut Self::Body

Source§

fn header_mut(&mut self) -> &mut Self::Header

Source§

fn set_header(&mut self, header: Self::Header)

Implementors§