diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml index 5a56c92..4e04c50 100644 --- a/.github/workflows/python-tests.yml +++ b/.github/workflows/python-tests.yml @@ -22,12 +22,12 @@ jobs: with: python-version: '3.10' - - name: Install Xvfb and dependencies + - name: Install system dependencies run: | sudo apt-get update sudo apt-get install -y xvfb libegl1-mesa - - name: Install dependencies + - name: Install Python dependencies run: | python -m pip install --upgrade pip pip install poetry @@ -35,7 +35,4 @@ jobs: - name: Run tests run: | - Xvfb :99 -screen 0 1920x1080x24 & - sleep 3 # Give Xvfb a moment to start - export DISPLAY=:99 - poetry run pytest -vvv --log-cli-level=DEBUG --maxfail=1 \ No newline at end of file + poetry run pytest -vvv --log-cli-level=DEBUG --setup-show --maxfail=1 diff --git a/bitcoin_safe/signature_manager.py b/bitcoin_safe/signature_manager.py index c8cfd1b..54a900a 100644 --- a/bitcoin_safe/signature_manager.py +++ b/bitcoin_safe/signature_manager.py @@ -117,6 +117,7 @@ def __init__( ) -> None: self.list_of_known_keys = list_of_known_keys if list_of_known_keys else [] self._gpg = None + self.import_known_keys() @staticmethod def _get_gpg_path() -> Optional[str]: @@ -171,7 +172,6 @@ def gpg(self): raise EnvironmentError("GnuPG is not installed on this system.") def import_known_keys(self) -> None: - self.gpg() for key in self.list_of_known_keys: self.gpg.import_keys(key.key) diff --git a/poetry.lock b/poetry.lock index d1ee155..9191b14 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1907,6 +1907,21 @@ pytest = "*" dev = ["pre-commit", "tox"] doc = ["sphinx", "sphinx-rtd-theme"] +[[package]] +name = "pytest-xvfb" +version = "3.0.0" +description = "A pytest plugin to run Xvfb (or Xephyr/Xvnc) for tests." +optional = false +python-versions = ">=3.7" +files = [ + {file = "pytest-xvfb-3.0.0.tar.gz", hash = "sha256:3746ab1f4d1159f03f751638d053689ccd284291b38b8fb03d3ebbe7bf69cfc0"}, + {file = "pytest_xvfb-3.0.0-py3-none-any.whl", hash = "sha256:352f247c788457ccdfcfeec8a47a2a6594c8eaf22f0302dae9e2635bb23975c2"}, +] + +[package.dependencies] +pytest = ">=2.8.1" +pyvirtualdisplay = ">=1.3" + [[package]] name = "python-bitcointx" version = "1.1.4" @@ -1959,6 +1974,17 @@ text-unidecode = ">=1.3" [package.extras] unidecode = ["Unidecode (>=1.1.1)"] +[[package]] +name = "pyvirtualdisplay" +version = "3.0" +description = "python wrapper for Xvfb, Xephyr and Xvnc" +optional = false +python-versions = "*" +files = [ + {file = "PyVirtualDisplay-3.0-py3-none-any.whl", hash = "sha256:40d4b8dfe4b8de8552e28eb367647f311f88a130bf837fe910e7f180d5477f0e"}, + {file = "PyVirtualDisplay-3.0.tar.gz", hash = "sha256:09755bc3ceb6eb725fb07eca5425f43f2358d3bf08e00d2a9b792a1aedd16159"}, +] + [[package]] name = "pyyaml" version = "6.0" @@ -2341,4 +2367,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more [metadata] lock-version = "2.0" python-versions = ">=3.9,<3.12" -content-hash = "cd2c42cf866bcb413b179586067f89aa66f2fb9801ec25580ad346b2620a43d6" +content-hash = "caee95bcd39e7ffbc69ad262ea0b62c57d085dd0b2dbcb19068ea33c719ee0f0" diff --git a/pyproject.toml b/pyproject.toml index 701a7bf..6baf002 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,6 +74,7 @@ python-gnupg = "^0.5.2" translate-toolkit = "^3.12.2" snakeviz = "^2.2.0" pyprof2calltree = "^1.4.5" +pytest-xvfb = "^3.0.0" [tool.briefcase.app.bitcoin-safe.macOS] universal_build = true diff --git a/tests/test_signers.py b/tests/test_signers.py index 9b36876..ad38137 100644 --- a/tests/test_signers.py +++ b/tests/test_signers.py @@ -228,18 +228,22 @@ def gen_multisig_descriptor_str( def pytest_bdk_setup_single_sig(network=bdk.Network.REGTEST) -> PyTestBDKSetup: - + logger.debug("pytest_bdk_setup_single_sig start") blockchain_config = get_blockchain_config(network=network) + logger.debug(f"blockchain_config = {blockchain_config}") blockchain = bdk.Blockchain(blockchain_config) + logger.debug(f"blockchain = {blockchain}") mnemonic = bdk.Mnemonic.from_string(test_seeds[0]) + logger.debug(f"mnemonic = {mnemonic}") descriptor = bdk.Descriptor.new_bip84( secret_key=bdk.DescriptorSecretKey(network, mnemonic, ""), keychain=bdk.KeychainKind.EXTERNAL, network=network, ) + logger.debug(f"descriptor = {descriptor}") wallet = bdk.Wallet( descriptor=descriptor, @@ -247,17 +251,20 @@ def pytest_bdk_setup_single_sig(network=bdk.Network.REGTEST) -> PyTestBDKSetup: network=network, database_config=bdk.DatabaseConfig.MEMORY(), ) + logger.debug(f"wallet = {wallet}") return PyTestBDKSetup(network=network, blockchain=blockchain, descriptors=[descriptor], wallets=[wallet]) @pytest.fixture def pytest_2_of_3_multisig_wallets() -> PyTestBDKSetup: + logger.debug("prepare fixture pytest_2_of_3_multisig_wallets") return pytest_bdk_setup_multisig(m=2, n=3, network=bdk.Network.REGTEST) @pytest.fixture def pytest_siglesig_wallet() -> PyTestBDKSetup: + logger.debug("prepare fixture pytest_siglesig_wallet") return pytest_bdk_setup_single_sig(network=bdk.Network.REGTEST)