[][src]Struct beacon_chain::test_utils::BeaconChainHarness

pub struct BeaconChainHarness<T: BeaconChainTypes> {
    pub chain: BeaconChain<T>,
    pub keypairs: Vec<Keypair>,
    pub spec: ChainSpec,
}

A testing harness which can instantiate a BeaconChain and populate it with blocks and attestations.

Used for testing.

Fields

chain: BeaconChain<T>keypairs: Vec<Keypair>spec: ChainSpec

Methods

impl<E: EthSpec> BeaconChainHarness<HarnessType<E>>[src]

pub fn new(eth_spec_instance: E, keypairs: Vec<Keypair>) -> Self[src]

Instantiate a new harness with validator_count initial validators.

pub fn advance_slot(&self)[src]

Advance the slot of the BeaconChain.

Does not produce blocks or attestations.

pub fn extend_chain(
    &self,
    num_blocks: usize,
    block_strategy: BlockStrategy,
    attestation_strategy: AttestationStrategy
) -> Hash256
[src]

Extend the BeaconChain with some blocks and attestations. Returns the root of the last-produced block (the head of the chain).

Chain will be extended by num_blocks blocks.

The block_strategy dictates where the new blocks will be placed.

The attestation_strategy dictates which validators will attest to the newly created blocks.

pub fn get_free_attestations(
    &self,
    attestation_strategy: &AttestationStrategy,
    state: &BeaconState<E>,
    head_block_root: Hash256,
    head_block_slot: Slot
) -> Vec<Attestation<E>>
[src]

Generates a Vec<Attestation> for some attestation strategy and head_block.

pub fn generate_two_forks_by_skipping_a_block(
    &self,
    honest_validators: &[usize],
    faulty_validators: &[usize],
    honest_fork_blocks: usize,
    faulty_fork_blocks: usize
) -> (Hash256, Hash256)
[src]

Creates two forks:

  • The "honest" fork: created by the honest_validators who have built honest_fork_blocks on the head
  • The "faulty" fork: created by the faulty_validators who skipped a slot and then built faulty_fork_blocks.

Returns (honest_head, faulty_head), the roots of the blocks at the top of each chain.

Auto Trait Implementations

impl<T> Send for BeaconChainHarness<T> where
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::EpochsPerHistoricalVector: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::EpochsPerSlashingsVector: Send,
    <T as BeaconChainTypes>::Eth1Chain: Send,
    <T as BeaconChainTypes>::EthSpec: EthSpec + Send,
    <T as BeaconChainTypes>::EventHandler: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::HistoricalRootsLimit: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::JustificationBitsLength: Send,
    <T as BeaconChainTypes>::LmdGhost: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxAttestations: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxAttesterSlashings: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxDeposits: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxPendingAttestations: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxProposerSlashings: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxTransfers: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxValidatorsPerCommittee: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxVoluntaryExits: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::ShardCount: Send,
    <T as BeaconChainTypes>::SlotClock: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::SlotsPerEth1VotingPeriod: Send,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::SlotsPerHistoricalRoot: Send,
    <T as BeaconChainTypes>::Store: Send + Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::ValidatorRegistryLimit: Send

impl<T> Unpin for BeaconChainHarness<T> where
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::EpochsPerHistoricalVector: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::EpochsPerSlashingsVector: Unpin,
    <T as BeaconChainTypes>::Eth1Chain: Unpin,
    <T as BeaconChainTypes>::EthSpec: EthSpec + Unpin,
    <T as BeaconChainTypes>::EventHandler: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::HistoricalRootsLimit: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::JustificationBitsLength: Unpin,
    <T as BeaconChainTypes>::LmdGhost: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxAttestations: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxAttesterSlashings: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxDeposits: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxPendingAttestations: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxProposerSlashings: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxTransfers: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxValidatorsPerCommittee: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxVoluntaryExits: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::ShardCount: Unpin,
    <T as BeaconChainTypes>::SlotClock: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::SlotsPerEth1VotingPeriod: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::SlotsPerHistoricalRoot: Unpin,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::ValidatorRegistryLimit: Unpin

impl<T> Sync for BeaconChainHarness<T> where
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::EpochsPerHistoricalVector: Send + Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::EpochsPerSlashingsVector: Send + Sync,
    <T as BeaconChainTypes>::Eth1Chain: Sync,
    <T as BeaconChainTypes>::EthSpec: EthSpec + Sync,
    <T as BeaconChainTypes>::EventHandler: Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::HistoricalRootsLimit: Send + Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::JustificationBitsLength: Send + Sync,
    <T as BeaconChainTypes>::LmdGhost: Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxAttestations: Send + Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxAttesterSlashings: Send + Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxDeposits: Send + Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxPendingAttestations: Send + Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxProposerSlashings: Send + Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxTransfers: Send + Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxValidatorsPerCommittee: Send + Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxVoluntaryExits: Send + Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::ShardCount: Send + Sync,
    <T as BeaconChainTypes>::SlotClock: Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::SlotsPerEth1VotingPeriod: Send + Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::SlotsPerHistoricalRoot: Send + Sync,
    <T as BeaconChainTypes>::Store: Send + Sync,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::ValidatorRegistryLimit: Send + Sync

impl<T> UnwindSafe for BeaconChainHarness<T> where
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::EpochsPerHistoricalVector: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::EpochsPerSlashingsVector: UnwindSafe,
    <T as BeaconChainTypes>::Eth1Chain: UnwindSafe,
    <T as BeaconChainTypes>::EthSpec: EthSpec + UnwindSafe,
    <T as BeaconChainTypes>::EventHandler: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::HistoricalRootsLimit: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::JustificationBitsLength: UnwindSafe,
    <T as BeaconChainTypes>::LmdGhost: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxAttestations: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxAttesterSlashings: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxDeposits: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxPendingAttestations: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxProposerSlashings: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxTransfers: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxValidatorsPerCommittee: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::MaxVoluntaryExits: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::ShardCount: UnwindSafe,
    <T as BeaconChainTypes>::SlotClock: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::SlotsPerEth1VotingPeriod: UnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::SlotsPerHistoricalRoot: UnwindSafe,
    <T as BeaconChainTypes>::Store: RefUnwindSafe,
    <<T as BeaconChainTypes>::EthSpec as EthSpec>::ValidatorRegistryLimit: UnwindSafe

impl<T> !RefUnwindSafe for BeaconChainHarness<T>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> SendSyncUnwindSafe for T where
    T: Send + Sync + UnwindSafe + ?Sized

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

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

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

impl<T> Erased for T