Esempio n. 1
0
    def on_channel_close(self, event: Dict, tx: Dict):
        log.info('on channel close: event=%s tx=%s' % (event, tx))
        # check if we have balance proof for the closing
        closing_participant = event['args']['closing_participant']
        channel_id = event['args']['channel_identifier']
        tx_data = tx[1]
        tx_balance_proof = BalanceProof(
            channel_identifier=tx_data[0],
            token_network_address=event['address'],
            balance_hash=tx_data[1],
            nonce=tx_data[2],
            additional_hash=tx_data[3],
            chain_id=int(self.web3.version.network),
            signature=encode_hex(tx_data[4]),
        )
        assert tx_balance_proof is not None
        assert is_address(closing_participant)
        assert is_channel_identifier(channel_id)

        pkey_to_mr = self.state_db.get_monitor_requests(channel_id)
        for (_, non_closing_signer), monitor_request in pkey_to_mr.items():
            if non_closing_signer == closing_participant:
                # we don't have to act on behalf of the closing participant
                continue
            # submit monitor request
            self.start_task(
                OnChannelClose(self.monitor_contract, monitor_request, self.private_key),
            )
Esempio n. 2
0
def test_client_multiple_topups(generate_raiden_clients):
    deposits = [1, 1, 2, 3, 5, 8, 13]
    c1, c2 = generate_raiden_clients(2)
    channel_identifier = c1.open_channel(c2.address)
    assert is_channel_identifier(channel_identifier)

    [c1.deposit_to_channel(c2.address, x) for x in deposits]
    channel_info = c1.get_own_channel_info(c2.address)
    assert sum(deposits) == channel_info['deposit']
 def get_monitor_request(self, channel_id: ChannelIdentifier) -> dict:
     assert is_channel_identifier(channel_id)
     # TODO unconfirmed topups
     c = self.conn.cursor()
     sql = 'SELECT rowid,* FROM `monitor_requests` WHERE `channel_id` = ?'
     c.execute(sql, [channel_id])
     result = c.fetchone()
     assert c.fetchone() is None
     return result
Esempio n. 4
0
def test_client_fee_info(generate_raiden_clients):
    c1, c2 = generate_raiden_clients(2)
    channel_identifier = c1.open_channel(c2.address)
    assert is_channel_identifier(channel_identifier)

    fi = c1.get_fee_info(c2.address, nonce=5, relative_fee=1000, chain_id=2)
    fee_info_signer = eth_verify(decode_hex(fi.signature), fi.serialize_bin())

    assert is_same_address(fee_info_signer, c1.address)

    assert fi.nonce == 5
    assert fi.relative_fee == 1000
    assert fi.chain_id == 2
 def check_monitor_request(monitor_request):
     balance_proof = monitor_request['balance_proof']
     assert is_channel_identifier(balance_proof['channel_identifier'])
     assert is_checksum_address(balance_proof['token_network_address'])
     assert is_checksum_address(monitor_request['monitor_address'])
 def delete_monitor_request(self, channel_id: ChannelIdentifier) -> None:
     assert is_channel_identifier(channel_id)
     c = self.conn.cursor()
     sql = 'DELETE FROM `monitor_requests` WHERE `channel_id` = ?'
     c.execute(sql, [channel_id])
     assert c.fetchone() is None
Esempio n. 7
0
 def check_monitor_request(monitor_request):
     balance_proof = monitor_request.balance_proof
     assert is_channel_identifier(balance_proof.channel_identifier)
     assert is_checksum_address(balance_proof.token_network_address)
     assert is_checksum_address(monitor_request.monitor_address)