Rework tests. Move all `process_voluntary_exit` tests to Deneb

This commit is contained in:
Hsiao-Wei Wang 2023-06-14 23:04:46 +08:00
parent 12fabf5854
commit 420f8baf67
No known key found for this signature in database
GPG Key ID: AE3D6B174F971DE4
5 changed files with 49 additions and 55 deletions

View File

@ -270,7 +270,7 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi
#### Modified `process_voluntary_exit` #### Modified `process_voluntary_exit`
Note: The function `process_voluntary_exit` is modified to use the a fixed fork version -- `CAPELLA_FORK_VERSION` -- for EIP-7044 *Note*: The function `process_voluntary_exit` is modified to use the a fixed fork version -- `CAPELLA_FORK_VERSION` -- for EIP-7044
```python ```python
def process_voluntary_exit(state: BeaconState, signed_voluntary_exit: SignedVoluntaryExit) -> None: def process_voluntary_exit(state: BeaconState, signed_voluntary_exit: SignedVoluntaryExit) -> None:

View File

@ -7,7 +7,6 @@ from eth2spec.test.context import (
from eth2spec.test.helpers.constants import ( from eth2spec.test.helpers.constants import (
BELLATRIX, BELLATRIX,
CAPELLA, CAPELLA,
DENEB,
) )
from eth2spec.test.helpers.keys import pubkey_to_privkey from eth2spec.test.helpers.keys import pubkey_to_privkey
from eth2spec.test.helpers.state import ( from eth2spec.test.helpers.state import (
@ -80,7 +79,7 @@ def test_voluntary_exit_with_current_fork_version_not_is_before_fork_epoch(spec,
) )
@with_phases([BELLATRIX, CAPELLA, DENEB]) @with_phases([BELLATRIX, CAPELLA])
@spec_state_test @spec_state_test
@always_bls @always_bls
def test_voluntary_exit_with_previous_fork_version_is_before_fork_epoch(spec, state): def test_voluntary_exit_with_previous_fork_version_is_before_fork_epoch(spec, state):

View File

@ -19,6 +19,7 @@ def test_invalid_voluntary_exit_with_current_fork_version_not_is_before_fork_epo
""" """
Since Deneb, the VoluntaryExit domain is fixed to `CAPELLA_FORK_VERSION` Since Deneb, the VoluntaryExit domain is fixed to `CAPELLA_FORK_VERSION`
""" """
assert state.fork.current_version != spec.config.CAPELLA_FORK_VERSION
yield from run_voluntary_exit_processing_test( yield from run_voluntary_exit_processing_test(
spec, spec,
state, state,
@ -28,7 +29,7 @@ def test_invalid_voluntary_exit_with_current_fork_version_not_is_before_fork_epo
) )
@with_phases([DENEB]) @with_deneb_and_later
@spec_state_test @spec_state_test
@always_bls @always_bls
def test_voluntary_exit_with_previous_fork_version_not_is_before_fork_epoch(spec, state): def test_voluntary_exit_with_previous_fork_version_not_is_before_fork_epoch(spec, state):
@ -37,9 +38,48 @@ def test_voluntary_exit_with_previous_fork_version_not_is_before_fork_epoch(spec
""" """
assert state.fork.previous_version != state.fork.current_version assert state.fork.previous_version != state.fork.current_version
yield from run_voluntary_exit_processing_test( if spec.fork == DENEB:
spec, assert state.fork.previous_version == spec.config.CAPELLA_FORK_VERSION
state, yield from run_voluntary_exit_processing_test(
fork_version=state.fork.previous_version, spec,
is_before_fork_epoch=False, state,
) fork_version=state.fork.previous_version,
is_before_fork_epoch=False,
)
else:
assert state.fork.previous_version != spec.config.CAPELLA_FORK_VERSION
yield from run_voluntary_exit_processing_test(
spec,
state,
fork_version=state.fork.previous_version,
is_before_fork_epoch=False,
valid=False,
)
@with_deneb_and_later
@spec_state_test
@always_bls
def test_voluntary_exit_with_previous_fork_version_is_before_fork_epoch(spec, state):
"""
Since Deneb, the VoluntaryExit domain is fixed to `CAPELLA_FORK_VERSION`
"""
assert state.fork.previous_version != state.fork.current_version
if spec.fork == DENEB:
assert state.fork.previous_version == spec.config.CAPELLA_FORK_VERSION
yield from run_voluntary_exit_processing_test(
spec,
state,
fork_version=state.fork.previous_version,
is_before_fork_epoch=True,
)
else:
assert state.fork.previous_version != spec.config.CAPELLA_FORK_VERSION
yield from run_voluntary_exit_processing_test(
spec,
state,
fork_version=state.fork.previous_version,
is_before_fork_epoch=True,
valid=False,
)

View File

@ -1,44 +0,0 @@
from eth2spec.test.context import (
always_bls,
spec_state_test,
with_eip6110_and_later,
)
from eth2spec.test.bellatrix.block_processing.test_process_voluntary_exit import (
run_voluntary_exit_processing_test,
)
@with_eip6110_and_later
@spec_state_test
@always_bls
def test_invalid_voluntary_exit_with_previous_fork_version_not_is_before_fork_epoch(spec, state):
"""
Since Deneb, the VoluntaryExit domain is fixed to `CAPELLA_FORK_VERSION`
"""
assert state.fork.previous_version != state.fork.current_version
yield from run_voluntary_exit_processing_test(
spec,
state,
fork_version=state.fork.previous_version,
is_before_fork_epoch=False,
valid=False,
)
@with_eip6110_and_later
@spec_state_test
@always_bls
def test_invalid_voluntary_exit_with_previous_fork_version_is_before_fork_epoch(spec, state):
"""
Since Deneb, the VoluntaryExit domain is fixed to `CAPELLA_FORK_VERSION`
"""
assert state.fork.previous_version != state.fork.current_version
yield from run_voluntary_exit_processing_test(
spec,
state,
fork_version=state.fork.previous_version,
is_before_fork_epoch=True,
valid=False,
)

View File

@ -45,7 +45,6 @@ if __name__ == "__main__":
_new_eip6110_mods = {key: 'eth2spec.test.eip6110.block_processing.test_process_' + key for key in [ _new_eip6110_mods = {key: 'eth2spec.test.eip6110.block_processing.test_process_' + key for key in [
'deposit_receipt', 'deposit_receipt',
'voluntary_exit',
]} ]}
eip6110_mods = combine_mods(_new_eip6110_mods, deneb_mods) eip6110_mods = combine_mods(_new_eip6110_mods, deneb_mods)