From ea43515eb036dd762739b0877449598abb3ce057 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Wed, 12 Jun 2019 16:55:59 +1000 Subject: [PATCH] committee cache: fix a test for shard delta changes --- eth2/types/src/beacon_state/committee_cache/tests.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/eth2/types/src/beacon_state/committee_cache/tests.rs b/eth2/types/src/beacon_state/committee_cache/tests.rs index ecaa3d457..4e31d0fb2 100644 --- a/eth2/types/src/beacon_state/committee_cache/tests.rs +++ b/eth2/types/src/beacon_state/committee_cache/tests.rs @@ -125,6 +125,9 @@ fn can_start_on_any_shard() { let mut state = new_state::(num_validators, slot); let spec = &FewValidatorsEthSpec::spec(); + let shard_delta = FewValidatorsEthSpec::get_shard_delta(num_validators); + let shard_count = FewValidatorsEthSpec::shard_count() as u64; + for i in 0..FewValidatorsEthSpec::shard_count() as u64 { state.latest_start_shard = i; @@ -132,10 +135,13 @@ fn can_start_on_any_shard() { assert_eq!(cache.shuffling_start_shard, i); let cache = CommitteeCache::initialized(&state, state.previous_epoch(), spec).unwrap(); - assert_eq!(cache.shuffling_start_shard, i); + assert_eq!( + cache.shuffling_start_shard, + (i + shard_count - shard_delta) % shard_count + ); let cache = CommitteeCache::initialized(&state, state.next_epoch(), spec).unwrap(); - assert_eq!(cache.shuffling_start_shard, i); + assert_eq!(cache.shuffling_start_shard, (i + shard_delta) % shard_count); } }