From c885e36a939bcb92a1b943337ad3c2c8153c4f11 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Sat, 2 Mar 2019 15:30:50 +1100 Subject: [PATCH] Add fn to BeaconChainHarness validator signing Signs some message using the priv key of some validator --- .../test_harness/src/beacon_chain_harness.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 43b60d506..f0fcad5cc 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 @@ -243,6 +243,25 @@ impl BeaconChainHarness { debug!("Free attestations processed."); } + pub fn validator_sign( + &self, + validator_index: usize, + message: &[u8], + epoch: Epoch, + domain_type: u64, + ) -> Option { + let validator = self.validators.get(validator_index)?; + + let domain = self + .beacon_chain + .state + .read() + .fork + .get_domain(epoch, domain_type); + + Some(Signature::new(message, domain, &validator.keypair.sk)) + } + pub fn add_deposit(&mut self, deposit: Deposit, keypair: Option) { self.beacon_chain.receive_deposit_for_inclusion(deposit);