Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scx1332/wip (#653) #654

Merged
merged 5 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 23 additions & 26 deletions goth/runner/probe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
from goth.runner.container.yagna import (
YagnaContainer,
YagnaContainerConfig,
PAYMENT_MOUNT_PATH,
)
from goth.runner.exceptions import KeyAlreadyExistsError, TemporalAssertionError
from goth.runner.log import LogConfig, monitored_logger
Expand All @@ -51,7 +50,6 @@
from goth.runner.probe.mixin import ActivityApiMixin, MarketApiMixin, PaymentApiMixin
from goth.runner.probe.rest_client import RestApiComponent


if TYPE_CHECKING:
from goth.runner import Runner

Expand Down Expand Up @@ -123,6 +121,28 @@ def __init__(
logger, {ProbeLoggingAdapter.EXTRA_PROBE_NAME: config.name}
)
config = self._setup_gftp_proxy(config)
private_key = None

# This part is a hack to allow using specific private keys for specific addresses
# Issue: https://github.com/golemfactory/goth/issues/655
if config.payment_id:
if config.payment_id.key.address == "63fc2ad3d021a4d7e64323529a55a9442c444da0":
self._logger.info("Setting private key 1...")
private_key = "5c8b9227cd5065c7e3f6b73826b8b42e198c4497f6688e3085d5ab3a6d520e74"
elif config.payment_id.key.address == "17ec8597ff92c3f44523bdc65bf0f1be632917ff":
self._logger.info("Setting private key 2...")
private_key = "29f3edee0ad3abf8e2699402e0e28cd6492c9be7eaab00d732a791c33552f797"
elif config.payment_id.key.address == "d1d84f0e28d6fedf03c73151f98df95139700aa7":
self._logger.info("Setting private key 3...")
private_key = "50c8b3fc81e908501c8cd0a60911633acaca1a567d1be8e769c5ae7007b34b23"
else:
self._logger.error(
"Private key not found for address: {}".format(config.payment_id.key.address)
)

if private_key:
config.environment["YAGNA_AUTOCONF_ID_SECRET"] = private_key

self.container = YagnaContainer(client, config, log_config)
self.cli = Cli(self.container).yagna
self._yagna_config = config
Expand Down Expand Up @@ -270,17 +290,13 @@ async def _start_container(self) -> None:
Performs all necessary steps to make the daemon ready for testing
(e.g. creating the default app key).
"""

self.container.start()

await self._wait_for_yagna_start(60)

await self.create_app_key()

# restart container to allow faster discovery of new identity in the network
self._logger.info("Restarting container after identity set")
self.container.restart()
await self._wait_for_yagna_start(60)

# Obtain the IP address of the container
self.ip_address = get_container_address(self._docker_client, self.container.name)
nginx_ip_address = self.runner.nginx_container_address
Expand All @@ -304,26 +320,7 @@ async def create_app_key(self, key_name: str = "test_key") -> str:

The key name can be specified via `key_name` parameter.
Return the key as string.

When `self.key_file` is set, this method also:
- creates ID based on `self.key_file`
- sets this new ID as default
- restarts the container ( https://github.com/golemfactory/yagna/issues/458 )
"""
address = None
if self._yagna_config.payment_id:
key_name = self._yagna_config.payment_id.key_file.name
key_file: str = str(PAYMENT_MOUNT_PATH / key_name)
self._logger.debug("create_id(alias=%s, key_file=%s", key_name, key_file)
try:
db_id = self.cli.id_create(alias=key_name, key_file=key_file)
address = db_id.address
self._logger.debug("create_id. alias=%s, address=%s", db_id, address)
except KeyAlreadyExistsError as e:
logger.critical("Id already exists : (%r)", e)
raise
db_id = self.cli.id_update(address, set_default=True)
self._logger.debug("update_id. result=%r", db_id)
try:
key = self.cli.app_key_create(key_name)
self._logger.debug("create_app_key. key_name=%s, key=%s", key_name, key)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exclude = '/(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|venv|\.svn|_build

[tool.poetry]
name = "goth"
version = "0.15.8"
version = "0.15.9"
description = "Golem Test Harness - integration testing framework"
authors = ["Golem Factory <[email protected]>"]
license = "GPL-3.0"
Expand Down