-
Notifications
You must be signed in to change notification settings - Fork 982
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3990 from mkalinin/upgrade-to-electra-tests
electra: Add more transition tests
- Loading branch information
Showing
10 changed files
with
206 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
98 changes: 98 additions & 0 deletions
98
tests/core/pyspec/eth2spec/test/electra/transition/test_operations.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
from eth2spec.test.context import ( | ||
ForkMeta, | ||
always_bls, | ||
with_fork_metas, | ||
with_presets, | ||
) | ||
from eth2spec.test.helpers.constants import ( | ||
AFTER_ELECTRA_PRE_POST_FORKS, | ||
MINIMAL, | ||
) | ||
from eth2spec.test.helpers.fork_transition import ( | ||
OperationType, | ||
run_transition_with_operation, | ||
) | ||
|
||
|
||
# | ||
# DepositRequest | ||
# | ||
|
||
@with_fork_metas([ForkMeta(pre_fork_name=pre, post_fork_name=post, fork_epoch=2) | ||
for pre, post in AFTER_ELECTRA_PRE_POST_FORKS]) | ||
@always_bls | ||
def test_transition_with_deposit_request_right_after_fork(state, fork_epoch, spec, post_spec, pre_tag, post_tag): | ||
""" | ||
Create a DEPOSIT_REQUEST right *after* the transition | ||
""" | ||
yield from run_transition_with_operation( | ||
state, | ||
fork_epoch, | ||
spec, | ||
post_spec, | ||
pre_tag, | ||
post_tag, | ||
operation_type=OperationType.DEPOSIT_REQUEST, | ||
operation_at_slot=fork_epoch * spec.SLOTS_PER_EPOCH, | ||
) | ||
|
||
|
||
# | ||
# WithdrawalRequest | ||
# | ||
|
||
@with_fork_metas([ForkMeta(pre_fork_name=pre, post_fork_name=post, fork_epoch=66) | ||
for pre, post in AFTER_ELECTRA_PRE_POST_FORKS]) | ||
@with_presets([MINIMAL], reason="too slow") | ||
@always_bls | ||
def test_transition_with_full_withdrawal_request_right_after_fork( | ||
state, | ||
fork_epoch, | ||
spec, | ||
post_spec, | ||
pre_tag, | ||
post_tag | ||
): | ||
""" | ||
Create a WITHDRAWAL_REQUEST right *after* the transition | ||
""" | ||
yield from run_transition_with_operation( | ||
state, | ||
fork_epoch, | ||
spec, | ||
post_spec, | ||
pre_tag, | ||
post_tag, | ||
operation_type=OperationType.WITHDRAWAL_REQUEST, | ||
operation_at_slot=fork_epoch * spec.SLOTS_PER_EPOCH, | ||
) | ||
|
||
|
||
# | ||
# ConsolidationRequest | ||
# | ||
|
||
@with_fork_metas([ForkMeta(pre_fork_name=pre, post_fork_name=post, fork_epoch=2) | ||
for pre, post in AFTER_ELECTRA_PRE_POST_FORKS]) | ||
@always_bls | ||
def test_transition_with_consolidation_request_right_after_fork( | ||
state, | ||
fork_epoch, | ||
spec, | ||
post_spec, | ||
pre_tag, | ||
post_tag | ||
): | ||
""" | ||
Create a CONSOLIDATION_REQUEST right *after* the transition | ||
""" | ||
yield from run_transition_with_operation( | ||
state, | ||
fork_epoch, | ||
spec, | ||
post_spec, | ||
pre_tag, | ||
post_tag, | ||
operation_type=OperationType.CONSOLIDATION_REQUEST, | ||
operation_at_slot=fork_epoch * spec.SLOTS_PER_EPOCH, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from eth2spec.test.helpers.withdrawals import ( | ||
set_eth1_withdrawal_credential_with_balance | ||
) | ||
|
||
|
||
def prepare_switch_to_compounding_request(spec, state, validator_index, address=None): | ||
validator = state.validators[validator_index] | ||
if not spec.has_execution_withdrawal_credential(validator): | ||
set_eth1_withdrawal_credential_with_balance(spec, state, validator_index, address=address) | ||
|
||
return spec.ConsolidationRequest( | ||
source_address=state.validators[validator_index].withdrawal_credentials[12:], | ||
source_pubkey=state.validators[validator_index].pubkey, | ||
target_pubkey=state.validators[validator_index].pubkey, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters