def test_success_regular_payload(spec, state): # pre-state state = build_state_with_complete_transition(spec, state) next_slot(spec, state) # execution payload execution_payload = build_empty_execution_payload(spec, state) yield from run_execution_payload_processing(spec, state, execution_payload)
def test_bad_timestamp_regular_payload(spec, state): # pre-state state = build_state_with_complete_transition(spec, state) next_slot(spec, state) # execution payload execution_payload = build_empty_execution_payload(spec, state) execution_payload.timestamp = execution_payload.timestamp + 1 yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
def test_gasused_gaslimit_plus_regular_payload(spec, state): # pre-state state = build_state_with_complete_transition(spec, state) next_slot(spec, state) # execution payload execution_payload = build_empty_execution_payload(spec, state) execution_payload.gas_used = execution_payload.gas_limit + uint64(1) yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
def test_bad_random_regular_payload(spec, state): # pre-state state = build_state_with_complete_transition(spec, state) next_slot(spec, state) # execution payload execution_payload = build_empty_execution_payload(spec, state) execution_payload.random = b'\x04' * 32 yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
def test_bad_parent_hash_regular_payload(spec, state): # pre-state state = build_state_with_complete_transition(spec, state) next_slot(spec, state) # execution payload execution_payload = build_empty_execution_payload(spec, state) execution_payload.parent_hash = spec.Hash32() yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
def test_gaslimit_minimum_minus_regular_payload(spec, state): # pre-state state = build_state_with_complete_transition(spec, state) next_slot(spec, state) state.latest_execution_payload_header.gas_limit = spec.MIN_GAS_LIMIT # execution payload execution_payload = build_empty_execution_payload(spec, state) execution_payload.gas_limit = execution_payload.gas_limit - uint64(1) yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
def test_bad_execution_regular_payload(spec, state): # completely valid payload, but execution itself fails (e.g. block exceeds gas limit) # pre-state state = build_state_with_complete_transition(spec, state) next_slot(spec, state) # execution payload execution_payload = build_empty_execution_payload(spec, state) yield from run_execution_payload_processing(spec, state, execution_payload, valid=False, execution_valid=False)
def test_non_empty_extra_data_regular_payload(spec, state): # pre-state state = build_state_with_complete_transition(spec, state) next_slot(spec, state) # execution payload execution_payload = build_empty_execution_payload(spec, state) execution_payload.extra_data = b'\x45' * 12 yield from run_execution_payload_processing(spec, state, execution_payload) assert state.latest_execution_payload_header.extra_data == execution_payload.extra_data
def test_gaslimit_lower_regular_payload(spec, state): # pre-state state = build_state_with_complete_transition(spec, state) next_slot(spec, state) # execution payload execution_payload = build_empty_execution_payload(spec, state) execution_payload.gas_limit = ( execution_payload.gas_limit - execution_payload.gas_limit // spec.GAS_LIMIT_DENOMINATOR + uint64(1) ) yield from run_execution_payload_processing(spec, state, execution_payload)
def test_gaslimit_upper_plus_regular_payload(spec, state): # pre-state state = build_state_with_complete_transition(spec, state) next_slot(spec, state) # execution payload execution_payload = build_empty_execution_payload(spec, state) execution_payload.gas_limit = ( execution_payload.gas_limit + execution_payload.gas_limit // spec.GAS_LIMIT_DENOMINATOR ) yield from run_execution_payload_processing(spec, state, execution_payload, valid=False)
def test_is_merge_block_and_is_execution_enabled(spec, state): for result in expected_results: (with_complete_transition, with_execution_payload, is_merge_block, is_execution_enabled) = result if with_complete_transition: state = build_state_with_complete_transition(spec, state) else: state = build_state_with_incomplete_transition(spec, state) body = spec.BeaconBlockBody() if with_execution_payload: body.execution_payload = build_empty_execution_payload(spec, state) assert spec.is_merge_block(state, body) == is_merge_block assert spec.is_execution_enabled(state, body) == is_execution_enabled
def test_success_merge_complete(spec, state): state = build_state_with_complete_transition(spec, state) assert spec.is_merge_transition_complete(state)