Add tests for shuffle uniqueness and large validators.

This commit is contained in:
NatoliChris 2018-07-17 16:12:48 +10:00
parent 9be81b138f
commit 5b922c7b41
No known key found for this signature in database
GPG Key ID: D3EA7DBA19945306

View File

@ -84,6 +84,31 @@ mod tests {
"10 validator shuffle was not as expected");
}
#[test]
fn test_shuffling_32() {
let s = get_shuffling(
&Sha256Digest::zero(),
&32,
&Config::standard());
assert_eq!(s,
vec!(30, 0, 31, 9, 22, 10, 20, 2, 13, 21, 1, 7, 29, 28, 3,
27, 6, 8, 25, 15, 12, 26, 4, 18, 16, 23, 19, 11, 14,
17, 5, 24),
"32 Validator shuffle was not as expected");
}
#[test]
fn test_shuffling_unique() {
let s = get_shuffling(
&Sha256Digest::zero(),
&20,
&Config::standard());
assert_eq!(false,
(1..s.len()).any(|i| s[i..].contains(&s[i-1])),
"Validator Shuffle Non-Unique")
}
#[test]
fn test_shuffling_with_gt_half_max_validators() {
let mut config = Config::standard();