Пример #1
0
def common_settle_state_tests(
    custom_token,
    token_network,
    channel_identifier,
    A,
    balance_A,
    B,
    balance_B,
    pre_account_balance_A,
    pre_account_balance_B,
    pre_balance_contract,
):
    # Make sure the correct amount of tokens has been transferred
    account_balance_A = custom_token.functions.balanceOf(A).call()
    account_balance_B = custom_token.functions.balanceOf(B).call()
    balance_contract = custom_token.functions.balanceOf(token_network.address).call()
    assert account_balance_A == pre_account_balance_A + balance_A
    assert account_balance_B == pre_account_balance_B + balance_B
    assert balance_contract == pre_balance_contract - balance_A - balance_B

    # Make sure channel data has been removed
    assert (
        token_network.functions.participants_hash_to_channel_identifier(
            get_participants_hash(A, B)
        ).call()
        == 0
    )

    # Make sure participant data has been removed
    (
        A_deposit,
        A_withdrawn,
        A_is_the_closer,
        A_balance_hash,
        A_nonce,
        _,
        _,
    ) = token_network.functions.getChannelParticipantInfo(channel_identifier, A, B).call()
    assert A_deposit == 0
    assert A_withdrawn == 0
    assert A_is_the_closer == 0
    assert A_balance_hash == fake_bytes(32)
    assert A_nonce == 0

    (
        B_deposit,
        B_withdrawn,
        B_is_the_closer,
        B_balance_hash,
        B_nonce,
        _,
        _,
    ) = token_network.functions.getChannelParticipantInfo(channel_identifier, B, A).call()
    assert B_deposit == 0
    assert B_withdrawn == 0
    assert B_is_the_closer == 0
    assert B_balance_hash == fake_bytes(32)
    assert B_nonce == 0
Пример #2
0
    def get(A, balance_A, B, balance_B, pre_account_balance_A,
            pre_account_balance_B, pre_balance_contract):
        # Make sure the correct amount of tokens has been transferred
        account_balance_A = custom_token.functions.balanceOf(A).call()
        account_balance_B = custom_token.functions.balanceOf(B).call()
        balance_contract = custom_token.functions.balanceOf(
            token_network.address).call()
        assert account_balance_A == pre_account_balance_A + balance_A
        assert account_balance_B == pre_account_balance_B + balance_B
        assert balance_contract == pre_balance_contract - balance_A - balance_B

        # Make sure channel data has been removed
        assert token_network.functions.participants_hash_to_channel_identifier(
            get_participants_hash(A, B)).call() == 0

        (_, settle_block_number,
         state) = token_network.functions.getChannelInfo(A, B).call()
        assert settle_block_number == 0  # settle_block_number
        assert state == CHANNEL_STATE_NONEXISTENT  # state

        # Make sure participant data has been removed
        (A_deposit, A_withdrawn, A_is_the_closer, A_balance_hash,
         A_nonce) = token_network.functions.getChannelParticipantInfo(
             A, B).call()
        assert A_deposit == 0
        assert A_withdrawn == 0
        assert A_is_the_closer == 0
        assert A_balance_hash == fake_bytes(32)
        assert A_nonce == 0

        (B_deposit, B_withdrawn, B_is_the_closer, B_balance_hash,
         B_nonce) = token_network.functions.getChannelParticipantInfo(
             B, A).call()
        assert B_deposit == 0
        assert B_withdrawn == 0
        assert B_is_the_closer == 0
        assert B_balance_hash == fake_bytes(32)
        assert B_nonce == 0