Example #1
0
def setup_tps(rpc_server, config_path, channelmanager_address, asset_address, deposit):
    """ Creates the required contract and the fully connected Raiden network
    prior to running the test.

    Args:
        rpc_server (str): A string in the format '{host}:{port}' used to define
            the JSON-RPC end-point.
        config_path (str): A full/relative path to the yaml configuration file.
        channelmanager_address (str): The address of the channel manager contract.
        asset_address (str): The address of the asset used for testing.
        deposit (int): The default deposit that will be made for all test nodes.
    """
    # TODO:
    #  - create/register the channel manager

    rpc_connection = rpc_server.split(':')
    rpc_connection = (rpc_connection[0], int(rpc_connection[1]))

    blockchain_service = BlockChainService(rpc_connection, channelmanager_address)
    blockchain_service.new_channel_manager_contract(asset_address=asset_address)

    with codecs.open(config_path, encoding='utf8') as handler:
        config = yaml.load(handler)

    node_addresses = []
    for node in config['nodes']:
        privkey = sha3('{}:{}'.format(node['host'], node['port']))
        node_addresses.append(privtoaddr(privkey))

    random_raiden_network(asset_address, blockchain_service, node_addresses, deposit)
Example #2
0
def setup_tps(rpc_server, config_path, channelmanager_address, asset_address,
              deposit):
    """ Creates the required contract and the fully connected Raiden network
    prior to running the test.

    Args:
        rpc_server (str): A string in the format '{host}:{port}' used to define
            the JSON-RPC end-point.
        config_path (str): A full/relative path to the yaml configuration file.
        channelmanager_address (str): The address of the channel manager contract.
        asset_address (str): The address of the asset used for testing.
        deposit (int): The default deposit that will be made for all test nodes.
    """
    # TODO:
    #  - create/register the channel manager

    rpc_connection = rpc_server.split(':')
    rpc_connection = (rpc_connection[0], int(rpc_connection[1]))

    blockchain_service = BlockChainService(rpc_connection,
                                           channelmanager_address)
    blockchain_service.new_channel_manager_contract(
        asset_address=asset_address)

    with codecs.open(config_path, encoding='utf8') as handler:
        config = yaml.load(handler)

    node_addresses = []
    for node in config['nodes']:
        privkey = sha3('{}:{}'.format(node['host'], node['port']))
        node_addresses.append(privtoaddr(privkey))

    random_raiden_network(asset_address, blockchain_service, node_addresses,
                          deposit)