From 5b922c7b41c2429054822cad9d3f63e83d25e0fe Mon Sep 17 00:00:00 2001 From: NatoliChris Date: Tue, 17 Jul 2018 16:12:48 +1000 Subject: [PATCH] Add tests for shuffle uniqueness and large validators. --- src/state/transition/shuffling.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/state/transition/shuffling.rs b/src/state/transition/shuffling.rs index 3525ec17c..d515de8c6 100644 --- a/src/state/transition/shuffling.rs +++ b/src/state/transition/shuffling.rs @@ -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();