openethereum/util/bloomchain/tests/util/random.rs
Marek Kotewicz 66f3c50842 revert removing blooms (#8066)
* Revert "fix traces, removed bloomchain crate, closes #7228, closes #7167"

This reverts commit 1bf62038678295e5586f02a38a0c5aab9a9efe62.

* Revert "fixed broken logs (#7934)"

This reverts commit f8a2e53f3e.

* fixed broken logs

* bring back old lock order

* remove migration v13

* revert CURRENT_VERSION to 12 in migration.rs
2018-03-12 20:15:55 +00:00

25 lines
529 B
Rust

extern crate rand;
use self::rand::random;
use bloomchain::Bloom;
pub fn generate_random_bloom() -> Bloom {
let mut res = [0u8; 256];
let p0 = random::<u8>();
let b0 = random::<u8>() % 8;
let p1 = random::<u8>();
let b1 = random::<u8>() % 8;
let p2 = random::<u8>();
let b2 = random::<u8>() % 8;
res[p0 as usize] |= 1 << b0;
res[p1 as usize] |= 1 << b1;
res[p2 as usize] |= 1 << b2;
From::from(res)
}
pub fn generate_n_random_blooms(n: usize) -> Vec<Bloom> {
(0..n).map(|_| generate_random_bloom()).collect()
}