Ejemplo n.º 1
0
def test_cli_select_chain_helper(project_dir, write_project_file, stdin,
                                 expected):
    project = Project(project_dir)
    project.config['chains.local_a.chain.class'] = 'populus.chain.TesterChain'
    project.config[
        'chains.local_a.web3.provider.class'] = 'web3.providers.ipc.IPCProvider'
    project.config['chains.local_a.web3.provider.settings.ipc_path'] = (
        get_geth_ipc_path(
            get_local_chain_datadir(project.project_dir, 'local_a')))
    project.config['chains.local_b.chain.class'] = 'populus.chain.TesterChain'
    project.config[
        'chains.local_b.web3.provider.class'] = 'web3.providers.ipc.IPCProvider'
    project.config['chains.local_b.web3.provider.settings.ipc_path'] = (
        get_geth_ipc_path(
            get_local_chain_datadir(project.project_dir, 'local_b')))
    project.config['chains.local_c.chain.class'] = 'populus.chain.TesterChain'
    project.config[
        'chains.local_c.web3.provider.class'] = 'web3.providers.ipc.IPCProvider'
    project.config['chains.local_c.web3.provider.settings.ipc_path'] = (
        get_geth_ipc_path(
            get_local_chain_datadir(project.project_dir, 'local_c')))

    @click.command()
    def wrapper():
        chain_name = select_chain(project)
        print("~~{0}~~".format(chain_name))

    runner = CliRunner()
    result = runner.invoke(wrapper, [], input=stdin)

    assert result.exit_code == 0
    assert expected in result.output
Ejemplo n.º 2
0
def test_reset_chain(project, write_project_file):
    data_dir = get_data_dir(project.project_dir, 'test-chain')
    ensure_path_exists(data_dir)

    chaindata_dir = get_chaindata_dir(data_dir)
    dapp_dir = get_dapp_dir(data_dir)
    nodekey_path = get_nodekey_path(data_dir)
    geth_ipc_path = get_geth_ipc_path(data_dir)

    ensure_path_exists(chaindata_dir)
    ensure_path_exists(dapp_dir)
    write_project_file(nodekey_path)
    write_project_file(geth_ipc_path)

    # sanity check
    assert os.path.exists(data_dir)
    assert os.path.exists(chaindata_dir)
    assert os.path.exists(dapp_dir)
    assert os.path.exists(nodekey_path)
    assert os.path.exists(geth_ipc_path)

    reset_chain(data_dir)

    assert os.path.exists(data_dir)
    assert not os.path.exists(chaindata_dir)
    assert not os.path.exists(dapp_dir)
    assert not os.path.exists(nodekey_path)
    assert not os.path.exists(geth_ipc_path)
Ejemplo n.º 3
0
def test_reset_chain(project, write_project_file):
    data_dir = get_data_dir(project.project_dir, 'test-chain')
    ensure_path_exists(data_dir)

    chaindata_dir = get_chaindata_dir(data_dir)
    dapp_dir = get_dapp_dir(data_dir)
    nodekey_path = get_nodekey_path(data_dir)
    geth_ipc_path = get_geth_ipc_path(data_dir)

    ensure_path_exists(chaindata_dir)
    ensure_path_exists(dapp_dir)
    write_project_file(nodekey_path)
    write_project_file(geth_ipc_path)

    # sanity check
    assert os.path.exists(data_dir)
    assert os.path.exists(chaindata_dir)
    assert os.path.exists(dapp_dir)
    assert os.path.exists(nodekey_path)
    assert os.path.exists(geth_ipc_path)

    reset_chain(data_dir)

    assert os.path.exists(data_dir)
    assert not os.path.exists(chaindata_dir)
    assert not os.path.exists(dapp_dir)
    assert not os.path.exists(nodekey_path)
    assert not os.path.exists(geth_ipc_path)
def test_project_directory_properties(project_dir):
    project = Project()

    contracts_source_dir = get_contracts_source_dir(project_dir)
    assert is_same_path(project.contracts_source_dir, contracts_source_dir)
    with pytest.warns(DeprecationWarning):
        assert is_same_path(project.contracts_dir, contracts_source_dir)

    build_asset_dir = get_build_asset_dir(project_dir)
    assert is_same_path(project.build_asset_dir, build_asset_dir)
    with pytest.warns(DeprecationWarning):
        assert is_same_path(project.build_dir, build_asset_dir)

    compiled_contracts_asset_path = get_compiled_contracts_asset_path(
        build_asset_dir)
    assert is_same_path(project.compiled_contracts_asset_path,
                        compiled_contracts_asset_path)
    with pytest.warns(DeprecationWarning):
        assert is_same_path(project.compiled_contracts_file_path,
                            compiled_contracts_asset_path)

    base_blockchain_storage_dir = get_base_blockchain_storage_dir(project_dir)
    assert is_same_path(project.base_blockchain_storage_dir,
                        base_blockchain_storage_dir)
    with pytest.warns(DeprecationWarning):
        assert is_same_path(project.blockchains_dir,
                            base_blockchain_storage_dir)

    data_dir = get_data_dir(project_dir, 'some-test-chain-name')
    with pytest.warns(DeprecationWarning):
        assert is_same_path(
            project.get_blockchain_data_dir('some-test-chain-name'), data_dir)

    chaindata_dir = get_chaindata_dir(data_dir)
    with pytest.warns(DeprecationWarning):
        assert is_same_path(
            project.get_blockchain_chaindata_dir('some-test-chain-name'),
            chaindata_dir)

    geth_ipc_path = get_geth_ipc_path(data_dir)
    with pytest.warns(DeprecationWarning):
        assert is_same_path(
            project.get_blockchain_ipc_path('some-test-chain-name'),
            geth_ipc_path)
Ejemplo n.º 5
0
 def get_blockchain_ipc_path(self, chain_name):
     warnings.warn(DeprecationWarning(
         "The `get_blockchain_ipc_path` function has been deprecated and "
         "will be removed in subsequent releases"
     ))
     return get_geth_ipc_path(self.get_blockchain_data_dir(chain_name))