示例#1
0
def test_clear_if_finalized_expired():
    """ Clear expired locks that we don't know the secret for. """
    initiator = factories.HOP6
    our_address = factories.ADDR
    amount = 3
    block_number = 10
    expire = block_number + factories.UNIT_REVEAL_TIMEOUT

    from_route, from_transfer = factories.make_from(
        amount,
        our_address,
        expire,
        initiator,
    )

    before_state = TargetState(
        our_address,
        from_route,
        from_transfer,
        block_number=expire,
    )
    before_iteration = TransitionResult(before_state, list())
    before_iteration = target.clear_if_finalized(before_iteration)

    assert before_iteration.new_state.from_transfer.secret is None
    assert before_iteration.new_state is not None

    expired_state = TargetState(
        our_address,
        from_route,
        from_transfer,
        block_number=expire + 1,
    )
    expired_iteration = TransitionResult(expired_state, list())
    expired_iteration = target.clear_if_finalized(expired_iteration)

    assert expired_iteration.new_state is None
def test_clear_if_finalized_expired():
    """ Clear expired locks that we don't know the secret for. """
    initiator = factories.HOP6
    our_address = factories.ADDR
    amount = 3
    block_number = 10
    expire = block_number + factories.UNIT_REVEAL_TIMEOUT

    from_route, from_transfer = factories.make_from(
        amount,
        our_address,
        expire,
        initiator,
    )

    before_state = TargetState(
        our_address,
        from_route,
        from_transfer,
        block_number=expire,
    )
    before_iteration = TransitionResult(before_state, list())
    before_iteration = target.clear_if_finalized(before_iteration)

    assert before_iteration.new_state.from_transfer.secret is None
    assert before_iteration.new_state is not None

    expired_state = TargetState(
        our_address,
        from_route,
        from_transfer,
        block_number=expire + 1,
    )
    expired_iteration = TransitionResult(expired_state, list())
    expired_iteration = target.clear_if_finalized(expired_iteration)

    assert expired_iteration.new_state is None
示例#3
0
def test_clear_if_finalized_payed():
    """ Clear if the transfer is paid with a proof. """
    initiator = factories.HOP6
    our_address = factories.ADDR
    amount = 3
    block_number = 1
    expire = block_number + factories.UNIT_REVEAL_TIMEOUT

    state = make_target_state(
        our_address,
        amount,
        block_number,
        initiator,
        expire,
    )
    state.state = 'balance_proof'
    iteration = TransitionResult(state, list())
    iteration = target.clear_if_finalized(iteration)

    assert iteration.new_state is None
def test_clear_if_finalized_payed():
    """ Clear if the transfer is paid with a proof. """
    initiator = factories.HOP6
    our_address = factories.ADDR
    amount = 3
    block_number = 1
    expire = block_number + factories.UNIT_REVEAL_TIMEOUT

    state = make_target_state(
        our_address,
        amount,
        block_number,
        initiator,
        expire,
    )
    state.state = 'balance_proof'
    iteration = TransitionResult(state, list())
    iteration = target.clear_if_finalized(iteration)

    assert iteration.new_state is None