Apply the trivial suggestions

This commit is contained in:
Hsiao-Wei Wang 2021-09-28 00:17:18 +08:00 committed by GitHub
parent c8d05c60ec
commit 2fa595f784
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 22 deletions

View File

@ -13,10 +13,10 @@ def validate_transition_execution_payload(spec, execution_payload):
assert spec.is_valid_terminal_pow_block(pow_block, pow_parent)
def run_process_merge_execution_payload(spec, block, parent_block, payload,
def run_validate_transition_execution_payload(spec, block, parent_block, payload,
valid=True, block_lookup_success=True):
"""
Run ``process_merge_execution_payload``, yielding:
Run ``validate_transition_execution_payload``, yielding:
- current block ('block')
- parent block ('parent_block')
- execution payload ('payload')
@ -100,7 +100,7 @@ def test_valid_terminal_pow_block_fail_just_after_terminal(spec, state):
@with_merge_and_later
@spec_state_test
def test_process_merge_execution_payload_success(spec, state):
def test_validate_transition_execution_payload_success(spec, state):
parent_block = prepare_empty_pow_block(spec)
parent_block.total_difficulty = spec.config.TERMINAL_TOTAL_DIFFICULTY - uint256(1)
block = prepare_empty_pow_block(spec)
@ -120,26 +120,26 @@ def test_process_merge_execution_payload_fail_block_lookup(spec, state):
block.parent_hash = parent_block.block_hash
block.total_difficulty = spec.config.TERMINAL_TOTAL_DIFFICULTY
payload = spec.ExecutionPayload()
yield from run_process_merge_execution_payload(spec, block, parent_block, payload,
yield from run_validate_transition_execution_payload(spec, block, parent_block, payload,
block_lookup_success=False)
@with_merge_and_later
@spec_state_test
def test_process_merge_execution_payload_fail_parent_block_lookup(spec, state):
def test_validate_transition_execution_payload_fail_parent_block_lookup(spec, state):
parent_block = prepare_empty_pow_block(spec)
parent_block.total_difficulty = spec.config.TERMINAL_TOTAL_DIFFICULTY - uint256(1)
block = prepare_empty_pow_block(spec)
block.total_difficulty = spec.config.TERMINAL_TOTAL_DIFFICULTY
payload = spec.ExecutionPayload()
payload.parent_hash = block.block_hash
yield from run_process_merge_execution_payload(spec, block, parent_block, payload,
yield from run_validate_transition_execution_payload(spec, block, parent_block, payload,
block_lookup_success=False)
@with_merge_and_later
@spec_state_test
def test_process_merge_execution_payload_fail_after_terminal(spec, state):
def test_validate_transition_execution_payload_fail_after_terminal(spec, state):
parent_block = prepare_empty_pow_block(spec)
parent_block.total_difficulty = spec.config.TERMINAL_TOTAL_DIFFICULTY
block = prepare_empty_pow_block(spec)
@ -147,4 +147,4 @@ def test_process_merge_execution_payload_fail_after_terminal(spec, state):
block.total_difficulty = spec.config.TERMINAL_TOTAL_DIFFICULTY + 1
payload = spec.ExecutionPayload()
payload.parent_hash = block.block_hash
yield from run_process_merge_execution_payload(spec, block, parent_block, payload, valid=False)
yield from run_validate_transition_execution_payload(spec, block, parent_block, payload, valid=False)

View File

@ -34,9 +34,8 @@ def test_fail_merge_block(spec, state):
@spec_state_test
def test_fail_merge_block_complete_transition(spec, state):
state = build_state_with_complete_transition(spec, state)
execution_payload = build_empty_execution_payload(spec, state)
body = spec.BeaconBlockBody()
body.execution_payload = execution_payload
body.execution_payload = build_empty_execution_payload(spec, state)
assert not spec.is_merge_block(state, body)
@ -44,9 +43,7 @@ def test_fail_merge_block_complete_transition(spec, state):
@spec_state_test
def test_fail_merge_block_no_execution_payload(spec, state):
state = build_state_with_incomplete_transition(spec, state)
execution_payload = spec.ExecutionPayload()
body = spec.BeaconBlockBody()
body.execution_payload = execution_payload
assert not spec.is_merge_block(state, body)
@ -54,9 +51,8 @@ def test_fail_merge_block_no_execution_payload(spec, state):
@spec_state_test
def test_success_merge_block(spec, state):
state = build_state_with_incomplete_transition(spec, state)
execution_payload = build_empty_execution_payload(spec, state)
body = spec.BeaconBlockBody()
body.execution_payload = execution_payload
body.execution_payload = build_empty_execution_payload(spec, state)
assert spec.is_merge_block(state, body)
@ -64,9 +60,7 @@ def test_success_merge_block(spec, state):
@spec_state_test
def test_failed_execution_enabled(spec, state):
state = build_state_with_incomplete_transition(spec, state)
execution_payload = spec.ExecutionPayload()
body = spec.BeaconBlockBody()
body.execution_payload = execution_payload
assert not spec.is_execution_enabled(state, body)
@ -74,9 +68,8 @@ def test_failed_execution_enabled(spec, state):
@spec_state_test
def test_success_execution_enabled_before_terminal(spec, state):
state = build_state_with_incomplete_transition(spec, state)
execution_payload = build_empty_execution_payload(spec, state)
body = spec.BeaconBlockBody()
body.execution_payload = execution_payload
body.execution_payload = build_empty_execution_payload(spec, state)
assert spec.is_execution_enabled(state, body)
@ -84,9 +77,7 @@ def test_success_execution_enabled_before_terminal(spec, state):
@spec_state_test
def test_success_execution_enabled_no_execution_payload(spec, state):
state = build_state_with_complete_transition(spec, state)
execution_payload = spec.ExecutionPayload()
body = spec.BeaconBlockBody()
body.execution_payload = execution_payload
assert spec.is_execution_enabled(state, body)
@ -94,7 +85,6 @@ def test_success_execution_enabled_no_execution_payload(spec, state):
@spec_state_test
def test_success_execution_enabled(spec, state):
state = build_state_with_complete_transition(spec, state)
execution_payload = build_empty_execution_payload(spec, state)
body = spec.BeaconBlockBody()
body.execution_payload = execution_payload
body.execution_payload = build_empty_execution_payload(spec, state)
assert spec.is_execution_enabled(state, body)