示例#1
0
def test_project_directory_properties(project_dir):
    project = Project()

    contracts_dir = get_contracts_dir(project_dir)
    assert is_same_path(project.contracts_dir, contracts_dir)

    build_dir = get_build_dir(project_dir)
    assert is_same_path(project.build_dir, build_dir)

    compiled_contracts_file_path = get_compiled_contracts_file_path(
        project_dir)
    assert is_same_path(project.compiled_contracts_file_path,
                        compiled_contracts_file_path)

    blockchains_dir = get_blockchains_dir(project_dir)
    assert is_same_path(project.blockchains_dir, blockchains_dir)

    data_dir = get_data_dir(project_dir, 'some-test-chain-name')
    assert is_same_path(
        project.get_blockchain_data_dir('some-test-chain-name'), data_dir)

    chaindata_dir = get_chaindata_dir(data_dir)
    assert is_same_path(
        project.get_blockchain_chaindata_dir('some-test-chain-name'),
        chaindata_dir)

    geth_ipc_path = get_geth_ipc_path(data_dir)
    assert is_same_path(
        project.get_blockchain_ipc_path('some-test-chain-name'), geth_ipc_path)
示例#2
0
def test_initializing_with_legacy_ini_config(project_dir, write_project_file):
    default_contracts_dir = get_contracts_dir(project_dir)
    os.rmdir(default_contracts_dir)

    write_project_file('populus.ini',
                       "[populus]\ncontracts_dir=./custom-contracts-dir")

    contracts_dir = os.path.join(project_dir, 'custom-contracts-dir')

    expected_paths = (
        os.path.join(project_dir, 'populus.json'),
        contracts_dir,
        os.path.join(contracts_dir, 'Greeter.sol'),
        os.path.join(project_dir, 'tests'),
        os.path.join(project_dir, 'tests', 'test_greeter.py'),
    )

    for path in expected_paths:
        assert not os.path.exists(path)

    runner = CliRunner()
    result = runner.invoke(main, ['init'], input='\n')

    assert result.exit_code == 0, result.output + str(result.exception)

    for path in expected_paths:
        assert os.path.exists(path), result.output
def test_compiling_project_contracts(project_dir, write_project_file, MATH):
    write_project_file('contracts/Math.sol', MATH['source'])

    source_paths, contract_data = compile_project_contracts(
        project_dir,
        get_contracts_dir(project_dir),
    )

    assert 'contracts/Math.sol' in source_paths

    assert 'Math' in contract_data
    assert 'code' in contract_data['Math']
    assert 'code_runtime' in contract_data['Math']
    assert 'abi' in contract_data['Math']
示例#4
0
文件: conftest.py 项目: 4gn3s/populus
def project_dir(tmpdir, monkeypatch):
    from populus.utils.filesystem import (
        ensure_path_exists,
        get_contracts_dir,
        get_build_dir,
        get_blockchains_dir,
    )

    _project_dir = str(tmpdir.mkdir("project-dir"))

    # setup project directories
    ensure_path_exists(get_contracts_dir(_project_dir))
    ensure_path_exists(get_build_dir(_project_dir))
    ensure_path_exists(get_blockchains_dir(_project_dir))

    monkeypatch.chdir(_project_dir)
    monkeypatch.syspath_prepend(_project_dir)

    return _project_dir
示例#5
0
def project_dir(tmpdir, monkeypatch):
    from populus.utils.filesystem import (
        ensure_path_exists,
        get_contracts_dir,
        get_build_dir,
        get_blockchains_dir,
    )

    _project_dir = str(tmpdir.mkdir("project-dir"))

    # setup project directories
    ensure_path_exists(get_contracts_dir(_project_dir))
    ensure_path_exists(get_build_dir(_project_dir))
    ensure_path_exists(get_blockchains_dir(_project_dir))

    monkeypatch.chdir(_project_dir)
    monkeypatch.syspath_prepend(_project_dir)

    return _project_dir
示例#6
0
def test_initializing_project(project_dir):
    contracts_dir = get_contracts_dir(project_dir)

    os.rmdir(contracts_dir)

    expected_paths = (contracts_dir, os.path.join(contracts_dir,
                                                  'Greeter.sol'),
                      os.path.join(project_dir, 'tests'),
                      os.path.join(project_dir, 'tests', 'test_greeter.py'),
                      os.path.join(project_dir, 'populus.ini'))

    for path in expected_paths:
        assert not os.path.exists(path)

    runner = CliRunner()
    result = runner.invoke(main, ['init'])

    assert result.exit_code == 0, result.output + str(result.exception)

    for path in expected_paths:
        assert os.path.exists(path)
def test_project_directory_properties(project_dir):
    project = Project()

    contracts_dir = get_contracts_dir(project_dir)
    assert is_same_path(project.contracts_dir, contracts_dir)

    build_dir = get_build_dir(project_dir)
    assert is_same_path(project.build_dir, build_dir)

    compiled_contracts_file_path = get_compiled_contracts_file_path(project_dir)
    assert is_same_path(project.compiled_contracts_file_path, compiled_contracts_file_path)

    blockchains_dir = get_blockchains_dir(project_dir)
    assert is_same_path(project.blockchains_dir, blockchains_dir)

    data_dir = get_data_dir(project_dir, "some-test-chain-name")
    assert is_same_path(project.get_blockchain_data_dir("some-test-chain-name"), data_dir)

    chaindata_dir = get_chaindata_dir(data_dir)
    assert is_same_path(project.get_blockchain_chaindata_dir("some-test-chain-name"), chaindata_dir)

    geth_ipc_path = get_geth_ipc_path(data_dir)
    assert is_same_path(project.get_blockchain_ipc_path("some-test-chain-name"), geth_ipc_path)
示例#8
0
def test_initializing_project(project_dir):
    contracts_dir = get_contracts_dir(project_dir)

    os.rmdir(contracts_dir)

    expected_paths = (
        contracts_dir,
        os.path.join(contracts_dir, 'Greeter.sol'),
        os.path.join(project_dir, 'tests'),
        os.path.join(project_dir, 'tests', 'test_greeter.py'),
        os.path.join(project_dir, 'populus.ini')
    )

    for path in expected_paths:
        assert not os.path.exists(path)

    runner = CliRunner()
    result = runner.invoke(main, ['init'])

    assert result.exit_code == 0, result.output + str(result.exception)

    for path in expected_paths:
        assert os.path.exists(path)
示例#9
0
 def contracts_dir(self):
     return get_contracts_dir(self.project_dir)
示例#10
0
 def contracts_dir(self):
     if 'compilation.contracts_dir' in self.config:
         return self.config['compilation.contracts_dir']
     else:
         return get_contracts_dir(self.project_dir)
示例#11
0
def find_project_contracts(project_dir):
    contracts_dir = get_contracts_dir(project_dir)

    return tuple(
        os.path.relpath(p) for p in recursive_find_files(contracts_dir, "*.sol")
    )
示例#12
0
 def contracts_dir(self):
     if self.config.has_option('populus', 'contracts_dir'):
         return self.config.get('populus', 'contracts_dir')
     else:
         return get_contracts_dir(self.project_dir)
示例#13
0
 def contracts_dir(self):
     if self.config.has_option("populus", "contracts_dir"):
         return self.config.get("populus", "contracts_dir")
     else:
         return get_contracts_dir(self.project_dir)