From ffebf88de533a8ee0b5274cb7b7825a642d8f550 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Fri, 31 May 2024 19:50:59 +0800 Subject: [PATCH] Fix testgen and test format --- ...s_execution_layer_consolidation_request.py | 28 +++++++++---------- tests/formats/operations/README.md | 3 +- tests/generators/operations/main.py | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_execution_layer_consolidation_request.py b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_execution_layer_consolidation_request.py index 95386f428..5e3f7877c 100644 --- a/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_execution_layer_consolidation_request.py +++ b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_execution_layer_consolidation_request.py @@ -405,7 +405,7 @@ def test_consolidation_balance_through_two_churn_epochs(spec, state): ) @spec_test @single_phase -def test_invalid_source_equals_target(spec, state): +def test_incorrect_source_equals_target(spec, state): current_epoch = spec.get_current_epoch(state) source_index = spec.get_active_validator_indices(state, current_epoch)[0] @@ -434,7 +434,7 @@ def test_invalid_source_equals_target(spec, state): ) @spec_test @single_phase -def test_invalid_exceed_pending_consolidations_limit(spec, state): +def test_incorrect_exceed_pending_consolidations_limit(spec, state): state.pending_consolidations = [ spec.PendingConsolidation(source_index=0, target_index=1) ] * spec.PENDING_CONSOLIDATIONS_LIMIT @@ -462,7 +462,7 @@ def test_invalid_exceed_pending_consolidations_limit(spec, state): @with_electra_and_later @spec_state_test @single_phase -def test_invalid_not_enough_consolidation_churn_available(spec, state): +def test_incorrect_not_enough_consolidation_churn_available(spec, state): state.validators = state.validators[0:2] state.pending_consolidations = [ spec.PendingConsolidation(source_index=0, target_index=1) @@ -495,7 +495,7 @@ def test_invalid_not_enough_consolidation_churn_available(spec, state): ) @spec_test @single_phase -def test_invalid_exited_source(spec, state): +def test_incorrect_exited_source(spec, state): # Set up an otherwise correct consolidation current_epoch = spec.get_current_epoch(state) source_index = spec.get_active_validator_indices(state, current_epoch)[0] @@ -527,7 +527,7 @@ def test_invalid_exited_source(spec, state): ) @spec_test @single_phase -def test_invalid_exited_target(spec, state): +def test_incorrect_exited_target(spec, state): # Set up an otherwise correct consolidation current_epoch = spec.get_current_epoch(state) source_index = spec.get_active_validator_indices(state, current_epoch)[0] @@ -557,7 +557,7 @@ def test_invalid_exited_target(spec, state): ) @spec_test @single_phase -def test_invalid_inactive_source(spec, state): +def test_incorrect_inactive_source(spec, state): # Set up an otherwise correct consolidation current_epoch = spec.get_current_epoch(state) source_index = spec.get_active_validator_indices(state, current_epoch)[0] @@ -589,7 +589,7 @@ def test_invalid_inactive_source(spec, state): ) @spec_test @single_phase -def test_invalid_inactive_target(spec, state): +def test_incorrect_inactive_target(spec, state): # Set up an otherwise correct consolidation current_epoch = spec.get_current_epoch(state) source_index = spec.get_active_validator_indices(state, current_epoch)[0] @@ -620,7 +620,7 @@ def test_invalid_inactive_target(spec, state): ) @spec_test @single_phase -def test_invalid_no_source_execution_withdrawal_credential(spec, state): +def test_incorrect_no_source_execution_withdrawal_credential(spec, state): # Set up a correct consolidation, but source does not have # an execution withdrawal credential current_epoch = spec.get_current_epoch(state) @@ -646,7 +646,7 @@ def test_invalid_no_source_execution_withdrawal_credential(spec, state): ) @spec_test @single_phase -def test_invalid_no_target_execution_withdrawal_credential(spec, state): +def test_incorrect_no_target_execution_withdrawal_credential(spec, state): # Set up a correct consolidation, but target does not have # an execution withdrawal credential current_epoch = spec.get_current_epoch(state) @@ -674,7 +674,7 @@ def test_invalid_no_target_execution_withdrawal_credential(spec, state): ) @spec_test @single_phase -def test_invalid_incorrect_source_address(spec, state): +def test_incorrect_incorrect_source_address(spec, state): # Set up an otherwise correct consolidation current_epoch = spec.get_current_epoch(state) source_index = spec.get_active_validator_indices(state, current_epoch)[0] @@ -704,7 +704,7 @@ def test_invalid_incorrect_source_address(spec, state): ) @spec_test @single_phase -def test_invalid_unknown_source_pubkey(spec, state): +def test_incorrect_unknown_source_pubkey(spec, state): # Set up an otherwise correct consolidation current_epoch = spec.get_current_epoch(state) source_index = spec.get_active_validator_indices(state, current_epoch)[0] @@ -734,7 +734,7 @@ def test_invalid_unknown_source_pubkey(spec, state): ) @spec_test @single_phase -def test_invalid_unknown_target_pubkey(spec, state): +def test_incorrect_unknown_target_pubkey(spec, state): # Set up an otherwise correct consolidation current_epoch = spec.get_current_epoch(state) source_index = spec.get_active_validator_indices(state, current_epoch)[0] @@ -760,7 +760,7 @@ def run_consolidation_processing(spec, state, consolidation, success=True): """ Run ``process_consolidation``, yielding: - pre-state ('pre') - - consolidation ('consolidation') + - execution_layer_consolidation_request ('execution_layer_consolidation_request') - post-state ('post'). If ``valid == False``, run expecting ``AssertionError`` """ @@ -778,7 +778,7 @@ def run_consolidation_processing(spec, state, consolidation, success=True): pre_state = state.copy() yield 'pre', state - yield 'consolidation', consolidation + yield 'execution_layer_consolidation_request', consolidation spec.process_execution_layer_consolidation_request(state, consolidation) diff --git a/tests/formats/operations/README.md b/tests/formats/operations/README.md index b020b5fd0..d69a70486 100644 --- a/tests/formats/operations/README.md +++ b/tests/formats/operations/README.md @@ -46,7 +46,8 @@ Operations: | `withdrawals` | `ExecutionPayload` | `execution_payload` | `process_withdrawals(state, execution_payload)` (new in Capella) | | `bls_to_execution_change` | `SignedBLSToExecutionChange` | `address_change` | `process_bls_to_execution_change(state, address_change)` (new in Capella) | | `deposit_receipt` | `DepositReceipt` | `deposit_receipt` | `process_deposit_receipt(state, deposit_receipt)` (new in Electra) | -| `exits` | `ExecutionLayerExit` | `execution_layer_exit` | `process_execution_layer_exit(state, execution_layer_exit)` (new in Electra) | +| `execution_layer_withdrawal_request` | `ExecutionLayerWithdrawalRequest` | `execution_layer_withdrawal_request` | `process_execution_layer_withdrawal_request(state, execution_layer_withdrawal_request)` (new in Electra) | +| `execution_layer_consolidation_request` | `ExecutionLayerConsolidationRequest` | `execution_layer_consolidation_request` | `process_execution_layer_consolidation_request(state, execution_layer_consolidation_request)` (new in Electra) | Note that `block_header` is not strictly an operation (and is a full `Block`), but processed in the same manner, and hence included here. diff --git a/tests/generators/operations/main.py b/tests/generators/operations/main.py index 85a5b64e3..d4ca89557 100644 --- a/tests/generators/operations/main.py +++ b/tests/generators/operations/main.py @@ -45,7 +45,7 @@ if __name__ == "__main__": _new_electra_mods = {key: 'eth2spec.test.electra.block_processing.test_process_' + key for key in [ 'attestation', - 'execution_layer_consolidation_requests', + 'execution_layer_consolidation_request', 'deposit_receipt', 'execution_layer_withdrawal_request', 'voluntary_exit'