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
impl TestBlockV2Builder
Sourcepub fn parent_hash(self, parent_hash: BlockHash) -> Self
pub fn parent_hash(self, parent_hash: BlockHash) -> Self
Sets the parent hash for the block.
Sourcepub fn state_root_hash(self, state_root_hash: Digest) -> Self
pub fn state_root_hash(self, state_root_hash: Digest) -> Self
Sets the state root hash for the block.
Sourcepub fn protocol_version(self, protocol_version: ProtocolVersion) -> Self
pub fn protocol_version(self, protocol_version: ProtocolVersion) -> Self
Sets the protocol version for the block.
Sourcepub fn transactions<'a, I: IntoIterator<Item = &'a Transaction>>(
self,
txns_iter: I,
) -> Self
pub fn transactions<'a, I: IntoIterator<Item = &'a Transaction>>( self, txns_iter: I, ) -> Self
Associates the given transactions with the created block.
Sourcepub fn rewarded_signatures(
self,
rewarded_signatures: RewardedSignatures,
) -> Self
pub fn rewarded_signatures( self, rewarded_signatures: RewardedSignatures, ) -> Self
Sets the height for the block.
Sourcepub fn random_transactions(self, count: usize, rng: &mut TestRng) -> Self
pub fn random_transactions(self, count: usize, rng: &mut TestRng) -> Self
Associates a number of random transactions with the created block.
Sourcepub fn switch_block(self, is_switch: bool) -> Self
pub fn switch_block(self, is_switch: bool) -> Self
Allows setting the created block to be switch block or not.
Sourcepub fn validator_weights(self, validator_weights: ValidatorWeights) -> Self
pub fn validator_weights(self, validator_weights: ValidatorWeights) -> Self
Sets the validator weights for the block.
Sourcepub fn build_versioned(self, rng: &mut TestRng) -> Block
pub fn build_versioned(self, rng: &mut TestRng) -> Block
Builds the block as a versioned block.
Sourcepub fn build_invalid(self, rng: &mut TestRng) -> BlockV2
pub fn build_invalid(self, rng: &mut TestRng) -> BlockV2
Builds a block that is invalid.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TestBlockV2Builder
impl RefUnwindSafe for TestBlockV2Builder
impl Send for TestBlockV2Builder
impl Sync for TestBlockV2Builder
impl Unpin for TestBlockV2Builder
impl UnwindSafe for TestBlockV2Builder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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