import os import time import pytest from populus.geth import ( ensure_account_exists, is_geth_available, ) from eth_rpc_client import Client skip_if_no_geth = pytest.mark.skipif( not is_geth_available(), reason="'geth' not available", ) BASE_DIR = os.path.abspath(os.path.dirname(__file__)) geth_project_dir = os.path.join(BASE_DIR, 'projects', 'test-01') @pytest.fixture(autouse=True) def project_test01_dir(monkeypatch): monkeypatch.chdir(geth_project_dir) return geth_project_dir @skip_if_no_geth def test_geth_node_as_fixture(geth_coinbase, geth_node, project_test01_dir, rpc_client): block_number = rpc_client.get_block_number()
import os import re import click import pytest from click.testing import CliRunner from populus.cli import main from populus.geth import ( is_geth_available, ) skip_if_no_geth = pytest.mark.skipif( not is_geth_available(), reason="'geth' not available", ) this_dir = os.path.dirname(__file__) @skip_if_no_geth def test_deployment(monkeypatch): monkeypatch.chdir(os.path.join(this_dir, 'projects/test-02/')) runner = CliRunner() result = runner.invoke(main, ['deploy', '--no-confirm', 'owned']) assert result.exit_code == 0, result.output # weak assertion but not sure what to do here. assert 'owned' in result.output assert re.search('owned \(0x[0-9a-f]{40}\)', result.output)
import os import shutil import pytest from populus.geth import is_geth_available, create_geth_account, get_geth_accounts, get_geth_data_dir PROJECTS_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "projects") skip_if_no_geth = pytest.mark.skipif(not is_geth_available(), reason="'geth' not available") @pytest.fixture def project_test05(monkeypatch): project_dir = os.path.join(PROJECTS_DIR, "test-05") monkeypatch.chdir(project_dir) default_chain_dir = get_geth_data_dir(project_dir, "default") if os.path.exists(default_chain_dir): shutil.rmtree(default_chain_dir) return project_dir @skip_if_no_geth def test_create_geth_account(project_test05): data_dir = get_geth_data_dir(project_test05, "default") assert not get_geth_accounts(data_dir) account_0 = create_geth_account(data_dir)