@@ -256,24 +256,28 @@ def test_get_shard_committees_at_slot(
256
256
'num_validators,'
257
257
'epoch_length,'
258
258
'target_committee_size,'
259
- 'shard_count'
259
+ 'shard_count,'
260
+ 'slot'
260
261
),
261
262
[
262
- (1000 , 20 , 10 , 100 ),
263
- (100 , 50 , 10 , 10 ),
264
- (20 , 10 , 3 , 10 ), # active_validators_size < epoch_length * target_committee_size
265
- # TODO: other slot cases
263
+ (1000 , 20 , 10 , 100 , 0 ),
264
+ (1000 , 20 , 10 , 100 , 5 ),
265
+ (1000 , 20 , 10 , 100 , 30 ),
266
+ (20 , 10 , 3 , 10 , 0 ), # active_validators_size < epoch_length * target_committee_size
267
+ (20 , 10 , 3 , 10 , 5 ),
268
+ (20 , 10 , 3 , 10 , 30 ),
266
269
],
267
270
)
268
271
def test_get_shuffling_is_complete (activated_genesis_validators ,
269
272
epoch_length ,
270
273
target_committee_size ,
271
- shard_count ):
274
+ shard_count ,
275
+ slot ):
272
276
shuffling = get_shuffling (
273
277
seed = b'\x35 ' * 32 ,
274
278
validators = activated_genesis_validators ,
275
279
crosslinking_start_shard = 0 ,
276
- slot = 0 ,
280
+ slot = slot ,
277
281
epoch_length = epoch_length ,
278
282
target_committee_size = target_committee_size ,
279
283
shard_count = shard_count ,
@@ -288,6 +292,7 @@ def test_get_shuffling_is_complete(activated_genesis_validators,
288
292
for validator_index in shard_committee .committee :
289
293
validators .add (validator_index )
290
294
295
+ assert len (activated_genesis_validators ) > 0
291
296
assert len (validators ) == len (activated_genesis_validators )
292
297
293
298
@@ -304,13 +309,13 @@ def test_get_shuffling_is_complete(activated_genesis_validators,
304
309
(20 , 10 , 3 , 10 ),
305
310
],
306
311
)
307
- def test_get_shuffling_handles_shard_wrap (genesis_validators ,
312
+ def test_get_shuffling_handles_shard_wrap (activated_genesis_validators ,
308
313
epoch_length ,
309
314
target_committee_size ,
310
315
shard_count ):
311
316
shuffling = get_shuffling (
312
317
seed = b'\x35 ' * 32 ,
313
- validators = genesis_validators ,
318
+ validators = activated_genesis_validators ,
314
319
crosslinking_start_shard = shard_count - 1 ,
315
320
slot = 0 ,
316
321
epoch_length = epoch_length ,
@@ -677,16 +682,16 @@ def _generate_some_indices(data, max_value_for_list):
677
682
678
683
679
684
@given (st .data ())
680
- def test_get_pubkey_for_indices (genesis_validators , data ):
681
- max_value_for_list = len (genesis_validators ) - 1
685
+ def test_get_pubkey_for_indices (activated_genesis_validators , data ):
686
+ max_value_for_list = len (activated_genesis_validators ) - 1
682
687
indices = _generate_some_indices (data , max_value_for_list )
683
- pubkeys = get_pubkey_for_indices (genesis_validators , indices )
688
+ pubkeys = get_pubkey_for_indices (activated_genesis_validators , indices )
684
689
685
690
assert len (indices ) == len (pubkeys )
686
691
687
692
for index , pubkey in enumerate (pubkeys ):
688
693
validator_index = indices [index ]
689
- assert genesis_validators [validator_index ].pubkey == pubkey
694
+ assert activated_genesis_validators [validator_index ].pubkey == pubkey
690
695
691
696
692
697
def _list_and_index (data , max_size = None , elements = st .integers ()):
@@ -699,8 +704,10 @@ def _list_and_index(data, max_size=None, elements=st.integers()):
699
704
700
705
701
706
@given (st .data ())
702
- def test_generate_aggregate_pubkeys (genesis_validators , sample_slashable_vote_data_params , data ):
703
- max_value_for_list = len (genesis_validators ) - 1
707
+ def test_generate_aggregate_pubkeys (activated_genesis_validators ,
708
+ sample_slashable_vote_data_params ,
709
+ data ):
710
+ max_value_for_list = len (activated_genesis_validators ) - 1
704
711
(indices , some_index ) = _list_and_index (
705
712
data ,
706
713
elements = st .integers (
@@ -718,13 +725,13 @@ def test_generate_aggregate_pubkeys(genesis_validators, sample_slashable_vote_da
718
725
719
726
votes = SlashableVoteData (** sample_slashable_vote_data_params )
720
727
721
- keys = generate_aggregate_pubkeys (genesis_validators , votes )
728
+ keys = generate_aggregate_pubkeys (activated_genesis_validators , votes )
722
729
assert len (keys ) == 2
723
730
724
731
(poc_0_key , poc_1_key ) = keys
725
732
726
- poc_0_keys = get_pubkey_for_indices (genesis_validators , custody_bit_0_indices )
727
- poc_1_keys = get_pubkey_for_indices (genesis_validators , custody_bit_1_indices )
733
+ poc_0_keys = get_pubkey_for_indices (activated_genesis_validators , custody_bit_0_indices )
734
+ poc_1_keys = get_pubkey_for_indices (activated_genesis_validators , custody_bit_1_indices )
728
735
729
736
assert bls .aggregate_pubkeys (poc_0_keys ) == poc_0_key
730
737
assert bls .aggregate_pubkeys (poc_1_keys ) == poc_1_key
@@ -840,13 +847,13 @@ def _create_slashable_vote_data_messages(params):
840
847
def test_verify_slashable_vote_data_signature (num_validators ,
841
848
privkeys ,
842
849
sample_beacon_state_params ,
843
- genesis_validators ,
850
+ activated_genesis_validators ,
844
851
genesis_balances ,
845
852
sample_slashable_vote_data_params ,
846
853
sample_fork_data_params ):
847
854
state = BeaconState (** sample_beacon_state_params ).copy (
848
- validator_registry = genesis_validators ,
849
- validator_balances = genesis_balances ,
855
+ validator_registry = activated_genesis_validators ,
856
+ validator_balances = activated_genesis_validators ,
850
857
fork_data = ForkData (** sample_fork_data_params ),
851
858
)
852
859
@@ -907,13 +914,13 @@ def test_verify_slashable_vote_data(num_validators,
907
914
needs_fork_data ,
908
915
privkeys ,
909
916
sample_beacon_state_params ,
910
- genesis_validators ,
917
+ activated_genesis_validators ,
911
918
genesis_balances ,
912
919
sample_slashable_vote_data_params ,
913
920
sample_fork_data_params ,
914
921
max_casper_votes ):
915
922
state = BeaconState (** sample_beacon_state_params ).copy (
916
- validator_registry = genesis_validators ,
923
+ validator_registry = activated_genesis_validators ,
917
924
validator_balances = genesis_balances ,
918
925
fork_data = ForkData (** sample_fork_data_params ),
919
926
)
0 commit comments