Struct TestBlockBuilder

Source
pub struct TestBlockBuilder { /* private fields */ }
Available on crate features std and testing only.
Expand description

A helper to build the blocks with various properties required for tests.

Implementations§

Source§

impl TestBlockV2Builder

Source

pub fn new() -> Self

Creates new TestBlockBuilder.

Source

pub fn parent_hash(self, parent_hash: BlockHash) -> Self

Sets the parent hash for the block.

Source

pub fn state_root_hash(self, state_root_hash: Digest) -> Self

Sets the state root hash for the block.

Source

pub fn timestamp(self, timestamp: Timestamp) -> Self

Sets the timestamp for the block.

Source

pub fn era(self, era: impl Into<EraId>) -> Self

Sets the era for the block

Source

pub fn height(self, height: u64) -> Self

Sets the height for the block.

Source

pub fn proposer(self, proposer: PublicKey) -> Self

Sets the block proposer.

Source

pub fn protocol_version(self, protocol_version: ProtocolVersion) -> Self

Sets the protocol version for the block.

Source

pub fn transactions<'a, I: IntoIterator<Item = &'a Transaction>>( self, txns_iter: I, ) -> Self

Associates the given transactions with the created block.

Source

pub fn rewarded_signatures( self, rewarded_signatures: RewardedSignatures, ) -> Self

Sets the height for the block.

Source

pub fn random_transactions(self, count: usize, rng: &mut TestRng) -> Self

Associates a number of random transactions with the created block.

Source

pub fn switch_block(self, is_switch: bool) -> Self

Allows setting the created block to be switch block or not.

Source

pub fn validator_weights(self, validator_weights: ValidatorWeights) -> Self

Sets the validator weights for the block.

Source

pub fn build(self, rng: &mut TestRng) -> BlockV2

Builds the block.

Source

pub fn build_versioned(self, rng: &mut TestRng) -> Block

Builds the block as a versioned block.

Source

pub fn build_invalid(self, rng: &mut TestRng) -> BlockV2

Builds a block that is invalid.

Trait Implementations§

Source§

impl Default for TestBlockV2Builder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more