Ejemplo n.º 1
0
def chain_reset(name, confirm):
    """
    Reset a test chain
    """
    data_dir = get_geth_data_dir(os.getcwd(), name)
    if confirm and not click.confirm("Are you sure you want to reset blockchain '{0}': {1}".format(name, data_dir)):  # NOQA
        raise click.Abort()
    reset_chain(data_dir)
Ejemplo n.º 2
0
def chain_reset(name, confirm):
    """
    Reset a test chain
    """
    data_dir = get_geth_data_dir(os.getcwd(), name)
    if confirm and not click.confirm(
            "Are you sure you want to reset blockchain '{0}': {1}".format(
                name, data_dir)):  # NOQA
        raise click.Abort()
    reset_chain(data_dir)
def project_test04(monkeypatch):
    project_dir = os.path.join(PROJECTS_DIR, 'test-04')
    monkeypatch.chdir(project_dir)

    data_dir = get_geth_data_dir(project_dir, 'default')
    ensure_path_exists(data_dir)
    reset_chain(data_dir)

    ensure_account_exists(data_dir)

    return project_dir
Ejemplo n.º 4
0
def project_test04(monkeypatch):
    project_dir = os.path.join(PROJECTS_DIR, 'test-04')
    monkeypatch.chdir(project_dir)

    data_dir = get_geth_data_dir(project_dir, 'default')
    ensure_path_exists(data_dir)
    reset_chain(data_dir)

    ensure_account_exists(data_dir)

    return project_dir
Ejemplo n.º 5
0
def geth_node(request, populus_config):
    from populus.geth import (
        run_geth_node,
        get_geth_data_dir,
        get_geth_logfile_path,
        ensure_account_exists,
        create_geth_account,
        reset_chain,
        wait_for_geth_to_start,
    )
    from populus.utils import (
        ensure_path_exists,
        kill_proc,
    )

    project_dir = populus_config.get_value(request, 'geth_project_dir')
    chain_name = populus_config.get_value(request, 'geth_chain_name')

    data_dir = get_geth_data_dir(project_dir, chain_name)

    logfile_name_fmt = "geth-{0}-{{0}}.log".format(request.module.__name__)
    logfile_path = get_geth_logfile_path(data_dir, logfile_name_fmt)

    ensure_path_exists(data_dir)
    ensure_account_exists(data_dir)

    num_accounts = populus_config.get_value(request, 'geth_num_accounts')
    if num_accounts > 1:
        for _ in range(num_accounts - 1):
            create_geth_account(data_dir)

    should_reset_chain = populus_config.get_value(request, 'geth_reset_chain')

    if should_reset_chain:
        reset_chain(data_dir)

    rpc_port = populus_config.get_value(request, 'geth_rpc_port')
    rpc_host = populus_config.get_value(request, 'geth_rpc_host')

    geth_max_wait = int(populus_config.get_value(request, 'geth_max_wait'))

    command, proc = run_geth_node(data_dir, rpc_addr=rpc_host,
                                  rpc_port=rpc_port, logfile=logfile_path,
                                  verbosity="6")

    wait_for_geth_to_start(proc, max_wait=geth_max_wait)

    yield proc
    kill_proc(proc)