def test_deposit_channel_event(
    get_accounts: Callable,
    token_network: Contract,
    create_channel: Callable,
    channel_deposit: Callable,
    event_handler: Callable,
) -> None:
    """ setTotalDeposit() from each participant causes a DEPOSIT event """
    ev_handler = event_handler(token_network)
    (A, B) = get_accounts(2)
    deposit_A = 10
    deposit_B = 15

    channel_identifier = create_channel(A, B)[0]

    txn_hash = channel_deposit(channel_identifier, A, deposit_A, B)
    assert (deposit_A == token_network.functions.getChannelParticipantInfo(
        channel_identifier, A, B).call()[0])

    ev_handler.add(txn_hash, ChannelEvent.DEPOSIT,
                   check_new_deposit(channel_identifier, A, deposit_A))

    txn_hash = channel_deposit(channel_identifier, B, deposit_B, A)
    ev_handler.add(txn_hash, ChannelEvent.DEPOSIT,
                   check_new_deposit(channel_identifier, B, deposit_B))

    ev_handler.check()
def test_deposit_channel_event(
    get_accounts,
    token_network,
    create_channel,
    channel_deposit,
    event_handler,
):
    ev_handler = event_handler(token_network)
    (A, B) = get_accounts(2)
    deposit_A = 10
    deposit_B = 15

    channel_identifier = create_channel(A, B)[0]

    txn_hash = channel_deposit(channel_identifier, A, deposit_A, B)

    ev_handler.add(
        txn_hash,
        ChannelEvent.DEPOSIT,
        check_new_deposit(channel_identifier, A, deposit_A),
    )

    txn_hash = channel_deposit(channel_identifier, B, deposit_B, A)
    ev_handler.add(
        txn_hash,
        ChannelEvent.DEPOSIT,
        check_new_deposit(channel_identifier, B, deposit_B),
    )

    ev_handler.check()
Esempio n. 3
0
def test_deposit_channel_event(
    get_accounts,
    token_network,
    create_channel,
    channel_deposit,
    event_handler,
):
    """ setTotalDeposit() from each participant causes a DEPOSIT event """
    ev_handler = event_handler(token_network)
    (A, B) = get_accounts(2)
    deposit_A = 10
    deposit_B = 15

    channel_identifier = create_channel(A, B)[0]

    txn_hash = channel_deposit(channel_identifier, A, deposit_A, B)

    ev_handler.add(
        txn_hash,
        ChannelEvent.DEPOSIT,
        check_new_deposit(channel_identifier, A, deposit_A),
    )

    txn_hash = channel_deposit(channel_identifier, B, deposit_B, A)
    ev_handler.add(
        txn_hash,
        ChannelEvent.DEPOSIT,
        check_new_deposit(channel_identifier, B, deposit_B),
    )

    ev_handler.check()
def test_channel_open_with_deposit_events(
    get_accounts: Callable,
    token_network: Contract,
    event_handler: Callable,
    assign_tokens: Callable,
) -> None:
    """A successful openChannelWithDeposit() causes an OPENED and DEPOSIT event"""
    ev_handler = event_handler(token_network)
    (A, B) = get_accounts(2)
    deposit = 100

    assign_tokens(A, deposit)
    txn_hash = call_and_transact(
        token_network.functions.openChannelWithDeposit(
            A, B, TEST_SETTLE_TIMEOUT_MIN, deposit),
        {"from": A},
    )
    channel_identifier = token_network.functions.getChannelIdentifier(
        A, B).call()

    ev_handler.add(
        txn_hash,
        ChannelEvent.OPENED,
        check_channel_opened(channel_identifier, A, B,
                             TEST_SETTLE_TIMEOUT_MIN),
    )
    ev_handler.add(
        txn_hash,
        ChannelEvent.DEPOSIT,
        check_new_deposit(channel_identifier, A, deposit),
    )
    ev_handler.check()
Esempio n. 5
0
def test_deposit_channel_event(get_accounts, token_network, create_channel,
                               channel_deposit, event_handler):
    ev_handler = event_handler(token_network)
    (A, B) = get_accounts(2)
    deposit_A = 10
    deposit_B = 15

    channel_identifier = create_channel(A, B)

    txn_hash = channel_deposit(channel_identifier, A, deposit_A)
    ev_handler.add(txn_hash, E_CHANNEL_NEW_DEPOSIT,
                   check_new_deposit(channel_identifier, A, deposit_A))

    txn_hash = channel_deposit(channel_identifier, B, deposit_B)
    ev_handler.add(txn_hash, E_CHANNEL_NEW_DEPOSIT,
                   check_new_deposit(channel_identifier, B, deposit_B))

    ev_handler.check()