Exemple #1
0
def find_project_contracts(project_dir,
                           contracts_rel_dir=DEFAULT_CONTRACTS_DIR):
    contracts_dir = os.path.join(project_dir, contracts_rel_dir)

    return tuple(
        os.path.relpath(p)
        for p in recursive_find_files(contracts_dir, "*.sol"))
def test_contract_factories(project, web3):
    from solc import compile_files
    from populus.utils.filesystem import recursive_find_files
    from populus.utils.contracts import (
        package_contracts,
        construct_contract_factories,
    )

    base_tests_dir = os.path.dirname(__file__)

    solidity_source_files = [
        os.path.relpath(contract_source_path)
        for contract_source_path
        in recursive_find_files(base_tests_dir, '*.sol')
    ] + [
        os.path.relpath(contract_source_path)
        for contract_source_path
        in recursive_find_files(project.contracts_dir, '*.sol')
    ]
    compiled_contracts = compile_files(solidity_source_files)
    test_contract_factories = construct_contract_factories(web3, compiled_contracts)
    return package_contracts(test_contract_factories)
def test_contract_factories(web3):
    from solc import compile_files
    from populus.utils.filesystem import recursive_find_files
    from populus.utils.contracts import (
        package_contracts,
        construct_contract_factories,
    )

    base_tests_dir = os.path.dirname(__file__)

    solidity_source_files = recursive_find_files(base_tests_dir, '*.sol')
    compiled_contracts = compile_files(solidity_source_files)
    test_contract_factories = construct_contract_factories(web3, compiled_contracts)
    return package_contracts(test_contract_factories)
def test_contract_factories(project):
    from solc import compile_files
    from populus.utils.filesystem import (
        recursive_find_files,
    )
    from populus.compilation import (
        find_project_contracts,
    )

    base_tests_dir = os.path.dirname(__file__)

    test_source_files = [
        os.path.relpath(source_path, project.project_dir)
        for source_path in recursive_find_files(base_tests_dir, 'Test*.sol')
    ]
    all_source_files = test_source_files + list(find_project_contracts(
        project.project_dir, project.contracts_dir,
    ))
    compiled_contracts = compile_files(all_source_files)
    for contract_name, contract_data in compiled_contracts.items():
        project.compiled_contracts.setdefault(contract_name, contract_data)
Exemple #5
0
 def get_test_source_paths(self, tests_dir):
     return (os.path.relpath(source_file_path)
             for source_file_path in recursive_find_files(
                 tests_dir, self.test_source_glob))
Exemple #6
0
 def get_project_source_paths(self, contracts_source_dir):
     return (os.path.relpath(source_file_path)
             for source_file_path in recursive_find_files(
                 contracts_source_dir, self.project_source_glob))
Exemple #7
0
def find_project_contracts(project_dir, contracts_rel_dir=DEFAULT_CONTRACTS_DIR):
    contracts_dir = os.path.join(project_dir, contracts_rel_dir)

    return tuple(
        os.path.relpath(p) for p in recursive_find_files(contracts_dir, "*.sol")
    )
Exemple #8
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")
    )