예제 #1
0
def test_success_non_activated(spec, state):
    transfer = get_valid_transfer(spec, state, signed=True)
    # un-activate so validator can transfer
    state.validators[
        transfer.sender].activation_eligibility_epoch = spec.FAR_FUTURE_EPOCH

    yield from run_transfer_processing(spec, state, transfer)
예제 #2
0
def test_incorrect_slot(state):
    transfer = get_valid_transfer(state, slot=state.slot + 1, signed=True)
    # un-activate so validator can transfer
    state.validator_registry[
        transfer.sender].activation_epoch = spec.FAR_FUTURE_EPOCH

    yield from run_transfer_processing(state, transfer, False)
예제 #3
0
def test_invalid_signature(spec, state):
    transfer = get_valid_transfer(spec, state)
    # un-activate so validator can transfer
    state.validators[
        transfer.sender].activation_eligibility_epoch = spec.FAR_FUTURE_EPOCH

    yield from run_transfer_processing(spec, state, transfer, False)
예제 #4
0
def test_invalid_pubkey(state):
    transfer = get_valid_transfer(state, signed=True)
    state.validator_registry[
        transfer.sender].withdrawal_credentials = spec.ZERO_HASH

    # un-activate so validator can transfer
    state.validator_registry[
        transfer.sender].activation_epoch = spec.FAR_FUTURE_EPOCH

    yield from run_transfer_processing(state, transfer, False)
예제 #5
0
def test_success_active_above_max_effective_fee(state):
    sender_index = get_active_validator_indices(state,
                                                get_current_epoch(state))[-1]
    state.balances[sender_index] = spec.MAX_EFFECTIVE_BALANCE + 1
    transfer = get_valid_transfer(state,
                                  sender_index=sender_index,
                                  amount=0,
                                  fee=1,
                                  signed=True)

    yield from run_transfer_processing(state, transfer)
예제 #6
0
def test_active_but_transfer_past_effective_balance(state):
    sender_index = get_active_validator_indices(state,
                                                get_current_epoch(state))[-1]
    amount = spec.MAX_EFFECTIVE_BALANCE // 32
    state.balances[sender_index] = spec.MAX_EFFECTIVE_BALANCE
    transfer = get_valid_transfer(state,
                                  sender_index=sender_index,
                                  amount=amount,
                                  fee=0,
                                  signed=True)

    yield from run_transfer_processing(state, transfer, False)
예제 #7
0
def test_insufficient_balance_for_amount_result_full(spec, state):
    sender_index = spec.get_active_validator_indices(
        state, spec.get_current_epoch(state))[-1]
    transfer = get_valid_transfer(spec,
                                  state,
                                  sender_index=sender_index,
                                  amount=state.balances[sender_index] + 1,
                                  fee=0,
                                  signed=True)

    # un-activate so validator can transfer
    state.validators[
        transfer.sender].activation_eligibility_epoch = spec.FAR_FUTURE_EPOCH

    yield from run_transfer_processing(spec, state, transfer, False)
예제 #8
0
def test_no_dust_sender(state):
    sender_index = get_active_validator_indices(state,
                                                get_current_epoch(state))[-1]
    balance = state.balances[sender_index]
    transfer = get_valid_transfer(state,
                                  sender_index=sender_index,
                                  amount=balance - spec.MIN_DEPOSIT_AMOUNT + 1,
                                  fee=0,
                                  signed=True)

    # un-activate so validator can transfer
    state.validator_registry[
        transfer.sender].activation_epoch = spec.FAR_FUTURE_EPOCH

    yield from run_transfer_processing(state, transfer, False)
예제 #9
0
def test_insufficient_balance(state):
    sender_index = get_active_validator_indices(state,
                                                get_current_epoch(state))[-1]
    state.balances[sender_index] = spec.MAX_EFFECTIVE_BALANCE
    transfer = get_valid_transfer(state,
                                  sender_index=sender_index,
                                  amount=1,
                                  fee=0,
                                  signed=True)

    # un-activate so validator can transfer
    state.validator_registry[
        transfer.sender].activation_epoch = spec.FAR_FUTURE_EPOCH

    yield from run_transfer_processing(state, transfer, False)
예제 #10
0
def test_transfer_clean_split_to_fee(spec, state):
    sender_index = spec.get_active_validator_indices(
        state, spec.get_current_epoch(state))[-1]
    state.balances[sender_index] = spec.MIN_DEPOSIT_AMOUNT
    transfer = get_valid_transfer(spec,
                                  state,
                                  sender_index=sender_index,
                                  amount=spec.MIN_DEPOSIT_AMOUNT // 2,
                                  fee=spec.MIN_DEPOSIT_AMOUNT // 2,
                                  signed=True)

    # un-activate so validator can transfer
    state.validators[
        transfer.sender].activation_eligibility_epoch = spec.FAR_FUTURE_EPOCH

    yield from run_transfer_processing(spec, state, transfer)
예제 #11
0
def test_insufficient_balance_duplicate_as_fee_and_amount(spec, state):
    sender_index = spec.get_active_validator_indices(
        state, spec.get_current_epoch(state))[-1]
    # Enough to pay fee fully without dust left, and amount fully without dust left, but not both.
    # Try to print money by using the full balance, twice.
    transfer = get_valid_transfer(spec,
                                  state,
                                  sender_index=sender_index,
                                  amount=state.balances[sender_index],
                                  fee=state.balances[sender_index],
                                  signed=True)

    # un-activate so validator can transfer
    state.validators[
        transfer.sender].activation_eligibility_epoch = spec.FAR_FUTURE_EPOCH

    yield from run_transfer_processing(spec, state, transfer, False)
예제 #12
0
def test_insufficient_balance_for_combined_result_full(spec, state):
    sender_index = spec.get_active_validator_indices(
        state, spec.get_current_epoch(state))[-1]
    # Enough to pay fee fully without dust left, and amount fully without dust left, but not both.
    state.balances[sender_index] = spec.MIN_DEPOSIT_AMOUNT * 2 + 1
    transfer = get_valid_transfer(spec,
                                  state,
                                  sender_index=sender_index,
                                  amount=spec.MIN_DEPOSIT_AMOUNT + 1,
                                  fee=spec.MIN_DEPOSIT_AMOUNT + 1,
                                  signed=True)

    # un-activate so validator can transfer
    state.validators[
        transfer.sender].activation_eligibility_epoch = spec.FAR_FUTURE_EPOCH

    yield from run_transfer_processing(spec, state, transfer, False)