PR feedback
This commit is contained in:
parent
7f720133fa
commit
9e8a9a26fd
|
@ -73,7 +73,7 @@ def next_epoch_with_attestations(state,
|
|||
return state, blocks, post_state
|
||||
|
||||
|
||||
def test_finality_from_genesis_rule_4(state):
|
||||
def test_finality_rule_4(state):
|
||||
test_state = deepcopy(state)
|
||||
|
||||
blocks = []
|
||||
|
@ -81,8 +81,10 @@ def test_finality_from_genesis_rule_4(state):
|
|||
prev_state, new_blocks, test_state = next_epoch_with_attestations(test_state, True, False)
|
||||
blocks += new_blocks
|
||||
|
||||
# justification/finalization skipped at GENESIS_EPOCH
|
||||
if epoch == 0:
|
||||
check_finality(test_state, prev_state, False, False, False)
|
||||
# justification/finalization skipped at GENESIS_EPOCH + 1
|
||||
elif epoch == 1:
|
||||
check_finality(test_state, prev_state, False, False, False)
|
||||
elif epoch == 2:
|
||||
|
@ -132,8 +134,6 @@ def test_finality_rule_2(state):
|
|||
|
||||
blocks = []
|
||||
for epoch in range(3):
|
||||
old_previous_justified_epoch = test_state.previous_justified_epoch
|
||||
old_previous_justified_root = test_state.previous_justified_root
|
||||
if epoch == 0:
|
||||
prev_state, new_blocks, test_state = next_epoch_with_attestations(test_state, True, False)
|
||||
check_finality(test_state, prev_state, True, False, False)
|
||||
|
@ -144,8 +144,8 @@ def test_finality_rule_2(state):
|
|||
prev_state, new_blocks, test_state = next_epoch_with_attestations(test_state, False, True)
|
||||
# finalized by rule 2
|
||||
check_finality(test_state, prev_state, True, False, True)
|
||||
assert test_state.finalized_epoch == old_previous_justified_epoch
|
||||
assert test_state.finalized_root == old_previous_justified_root
|
||||
assert test_state.finalized_epoch == prev_state.previous_justified_epoch
|
||||
assert test_state.finalized_root == prev_state.previous_justified_root
|
||||
|
||||
blocks += new_blocks
|
||||
|
||||
|
@ -170,19 +170,24 @@ def test_finality_rule_3(state):
|
|||
blocks += new_blocks
|
||||
check_finality(test_state, prev_state, True, False, False)
|
||||
|
||||
# In epoch N, JE is set to N, prev JE is set to N-1
|
||||
prev_state, new_blocks, test_state = next_epoch_with_attestations(test_state, True, False)
|
||||
blocks += new_blocks
|
||||
check_finality(test_state, prev_state, True, True, True)
|
||||
|
||||
# In epoch N+1, JE is N, prev JE is N-1, and not enough messages get in to do anything
|
||||
prev_state, new_blocks, test_state = next_epoch_with_attestations(test_state, False, False)
|
||||
blocks += new_blocks
|
||||
check_finality(test_state, prev_state, False, True, False)
|
||||
|
||||
# In epoch N+2, JE is N, prev JE is N, and enough messages from the previous epoch get in to justify N+1.
|
||||
# N+1 now becomes the JE. Not enough messages from epoch N+2 itself get in to justify N+2
|
||||
prev_state, new_blocks, test_state = next_epoch_with_attestations(test_state, False, True)
|
||||
blocks += new_blocks
|
||||
# rule 2
|
||||
check_finality(test_state, prev_state, True, False, True)
|
||||
|
||||
# In epoch N+3, LJE is N+1, prev LJE is N, and enough messages get in to justify epochs N+2 and N+3.
|
||||
prev_state, new_blocks, test_state = next_epoch_with_attestations(test_state, True, True)
|
||||
blocks += new_blocks
|
||||
# rule 3
|
||||
|
|
Loading…
Reference in New Issue