decided against moving test_utils (lighthouse-246)

This commit is contained in:
thojest 2019-02-22 16:05:52 +01:00
parent 7a382043e1
commit 278b41c8ef
4 changed files with 0 additions and 50 deletions

View File

@ -15,7 +15,6 @@ members = [
"eth2/utils/ssz_derive", "eth2/utils/ssz_derive",
"eth2/utils/swap_or_not_shuffle", "eth2/utils/swap_or_not_shuffle",
"eth2/utils/fisher_yates_shuffle", "eth2/utils/fisher_yates_shuffle",
"eth2/utils/test_random",
"eth2/utils/test_random_derive", "eth2/utils/test_random_derive",
"beacon_node", "beacon_node",
"beacon_node/db", "beacon_node/db",

View File

@ -1,8 +0,0 @@
[package]
name = "test_random"
version = "0.1.0"
authors = ["thojest <thojest@gmail.com>"]
edition = "2018"
[dependencies]
rand = "0.5.5"

View File

@ -1,39 +0,0 @@
use rand::RngCore;
pub trait TestRandom<T>
where
T: RngCore,
{
fn random_for_test(rng: &mut T) -> Self;
}
impl<T: RngCore> TestRandom<T> for u64 {
fn random_for_test(rng: &mut T) -> Self {
rng.next_u64()
}
}
impl<T: RngCore> TestRandom<T> for u32 {
fn random_for_test(rng: &mut T) -> Self {
rng.next_u32()
}
}
impl<T: RngCore> TestRandom<T> for usize {
fn random_for_test(rng: &mut T) -> Self {
rng.next_u32() as usize
}
}
impl<T: RngCore, U> TestRandom<T> for Vec<U>
where
U: TestRandom<T>,
{
fn random_for_test(rng: &mut T) -> Self {
vec![
<U>::random_for_test(rng),
<U>::random_for_test(rng),
<U>::random_for_test(rng),
]
}
}

View File

@ -11,5 +11,3 @@ proc-macro = true
[dependencies] [dependencies]
syn = "0.15" syn = "0.15"
quote = "0.6" quote = "0.6"
test_random = {path = "../test_random"}