def test_success_double(state):
    attester_slashing = get_valid_attester_slashing(state)

    pre_state, post_state = run_attester_slashing_processing(
        state, attester_slashing)

    return pre_state, attester_slashing, post_state
def test_no_double_or_surround(state):
    attester_slashing = get_valid_attester_slashing(state)

    attester_slashing.attestation_1.data.slot += spec.SLOTS_PER_EPOCH

    pre_state, post_state = run_attester_slashing_processing(state, attester_slashing, False)

    return pre_state, attester_slashing, post_state
def test_same_data(state):
    attester_slashing = get_valid_attester_slashing(state)

    attester_slashing.attestation_1.data = attester_slashing.attestation_2.data

    pre_state, post_state = run_attester_slashing_processing(state, attester_slashing, False)

    return pre_state, attester_slashing, post_state
def test_custody_bit_0_and_1(state):
    attester_slashing = get_valid_attester_slashing(state)

    attester_slashing.attestation_1.custody_bit_1_indices = (
        attester_slashing.attestation_1.custody_bit_0_indices
    )
    pre_state, post_state = run_attester_slashing_processing(state, attester_slashing, False)

    return pre_state, attester_slashing, post_state
def test_no_double_or_surround(state):
    attester_slashing = get_valid_attester_slashing(state)

    attester_slashing.attestation_1.data.target_epoch += 1

    pre_state, post_state = run_attester_slashing_processing(
        state, attester_slashing, False)

    return pre_state, attester_slashing, post_state
def test_participants_already_slashed(state):
    attester_slashing = get_valid_attester_slashing(state)

    # set all indices to slashed
    attestation_1 = attester_slashing.attestation_1
    validator_indices = attestation_1.custody_bit_0_indices + attestation_1.custody_bit_1_indices
    for index in validator_indices:
        state.validator_registry[index].slashed = True

    pre_state, post_state = run_attester_slashing_processing(state, attester_slashing, False)

    return pre_state, attester_slashing, post_state
def test_success_surround(state):
    next_epoch(state)
    state.current_justified_epoch += 1
    attester_slashing = get_valid_attester_slashing(state)

    # set attestion1 to surround attestation 2
    attester_slashing.attestation_1.data.source_epoch = attester_slashing.attestation_2.data.source_epoch - 1
    attester_slashing.attestation_1.data.slot = attester_slashing.attestation_2.data.slot + spec.SLOTS_PER_EPOCH

    pre_state, post_state = run_attester_slashing_processing(state, attester_slashing)

    return pre_state, attester_slashing, post_state