diff --git a/beacon_node/beacon_chain/test_harness/src/beacon_chain_harness.rs b/beacon_node/beacon_chain/test_harness/src/beacon_chain_harness.rs index d6608cd39..2f375f7fa 100644 --- a/beacon_node/beacon_chain/test_harness/src/beacon_chain_harness.rs +++ b/beacon_node/beacon_chain/test_harness/src/beacon_chain_harness.rs @@ -240,6 +240,11 @@ impl BeaconChainHarness { debug!("Free attestations processed."); } + /// Signs a message using some validators secret key with the `Fork` info from the latest state + /// of the `BeaconChain`. + /// + /// Useful for producing slashable messages and other objects that `BeaconChainHarness` does + /// not produce naturally. pub fn validator_sign( &self, validator_index: usize, @@ -259,6 +264,11 @@ impl BeaconChainHarness { Some(Signature::new(message, domain, &validator.keypair.sk)) } + /// Submit a deposit to the `BeaconChain` and, if given a keypair, create a new + /// `ValidatorHarness` instance for this validator. + /// + /// If a new `ValidatorHarness` was created, the validator should become fully operational as + /// if the validator were created during `BeaconChainHarness` instantiation. pub fn add_deposit(&mut self, deposit: Deposit, keypair: Option) { self.beacon_chain.receive_deposit_for_inclusion(deposit); @@ -270,16 +280,19 @@ impl BeaconChainHarness { } } + /// Submit a proposer slashing to the `BeaconChain` for inclusion in some block. pub fn add_proposer_slashing(&mut self, proposer_slashing: ProposerSlashing) { self.beacon_chain .receive_proposer_slashing_for_inclusion(proposer_slashing); } + /// Submit an attester slashing to the `BeaconChain` for inclusion in some block. pub fn add_attester_slashing(&mut self, attester_slashing: AttesterSlashing) { self.beacon_chain .receive_attester_slashing_for_inclusion(attester_slashing); } + /// Executes the fork choice rule on the `BeaconChain`, selecting a new canonical head. pub fn run_fork_choice(&mut self) { self.beacon_chain.fork_choice().unwrap() }