Skip to content
Permalink
Browse files

replace costly generation by a one-time generation

  • Loading branch information...
vincenthz committed May 16, 2019
1 parent de8b530 commit 4914204a79c0ffa25baba564b08587ca64a996b1
Showing with 16 additions and 4 deletions.
  1. +7 −2 chain-impl-mockchain/src/block/header.rs
  2. +9 −2 chain-impl-mockchain/src/certificate.rs
@@ -295,7 +295,8 @@ impl property::Header for Header {
mod test {
use super::*;
use crate::block::ConsensusVersion;
use chain_crypto::AsymmetricKey;
use chain_crypto::{AsymmetricKey, SecretKey, SumEd25519_12};
use lazy_static::lazy_static;
use num_traits::FromPrimitive;
use quickcheck::{Arbitrary, Gen, TestResult};

@@ -359,7 +360,11 @@ mod test {
};

let kes_proof = {
let mut sk = Arbitrary::arbitrary(g);
lazy_static! {
static ref SK_FIRST: SecretKey<SumEd25519_12> =
{ SecretKey::generate(&mut ChaChaRng::from_seed([0; 32])) };
}
let mut sk = SK_FIRST.clone(); // Arbitrary::arbitrary(g);
let signature = Signature::generate_update(&mut sk, &[0u8, 1, 2, 3]);
KESSignature(signature)
};
@@ -386,7 +386,8 @@ impl Readable for StakePoolRetirement {
mod test {
use super::*;
use crate::leadership::genesis::GenesisPraosLeader;
use chain_crypto::SecretKey;
use chain_crypto::{PublicKey, SecretKey, SumEd25519_12};
use lazy_static::lazy_static;
use quickcheck::{Arbitrary, Gen};

impl Arbitrary for Certificate {
@@ -444,13 +445,19 @@ mod test {
for byte in seed.iter_mut() {
*byte = Arbitrary::arbitrary(g);
}
lazy_static! {
static ref PK_KES: PublicKey<SumEd25519_12> = {
let sk = SecretKey::generate(&mut rand_chacha::ChaChaRng::from_seed([0; 32]));
sk.to_public()
};
}
let mut rng = rand_chacha::ChaChaRng::from_seed(seed);
StakePoolInfo {
serial: Arbitrary::arbitrary(g),
owners: vec![Arbitrary::arbitrary(g)],
initial_key: GenesisPraosLeader {
vrf_public_key: SecretKey::generate(&mut rng).to_public(),
kes_public_key: SecretKey::generate(&mut rng).to_public(),
kes_public_key: PK_KES.clone(),
},
}
}

0 comments on commit 4914204

Please sign in to comment.
You can’t perform that action at this time.