Fix flaky staking test (#5812)

* Fix flaky staking test

* Better doc

* Update frame/staking/src/tests.rs

Co-Authored-By: Benjamin Kampmann <ben@gnunicorn.org>

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Benjamin Kampmann <ben@gnunicorn.org>
This commit is contained in:
Kian Paimani
2020-04-28 12:04:23 +02:00
committed by GitHub
parent 8ae3ecf3cd
commit 00378d4092
2 changed files with 18 additions and 15 deletions
@@ -74,6 +74,8 @@ pub struct OffchainState {
pub local_storage: InMemOffchainStorage,
/// Current timestamp (unix millis)
pub timestamp: u64,
/// A supposedly random seed.
pub seed: [u8; 32],
}
impl OffchainState {
@@ -165,12 +167,7 @@ impl offchain::Externalities for TestOffchainExt {
}
fn random_seed(&mut self) -> [u8; 32] {
use rand::{SeedableRng, RngCore};
use rand::rngs::SmallRng;
let mut seed = [0u8; 32];
let mut small_rng = SmallRng::from_entropy();
small_rng.fill_bytes(&mut seed);
seed
self.0.read().seed
}
fn local_storage_set(&mut self, kind: StorageKind, key: &[u8], value: &[u8]) {