2024-11-11 14:40:05 +00:00
|
|
|
import inspect
|
2024-06-11 11:36:20 +00:00
|
|
|
import os
|
2024-10-11 08:08:39 +00:00
|
|
|
import threading
|
2024-06-11 11:36:20 +00:00
|
|
|
from dataclasses import dataclass
|
2024-10-11 08:08:39 +00:00
|
|
|
import pytest as pytest
|
2024-11-11 14:40:05 +00:00
|
|
|
from src.libs.custom_logger import get_custom_logger
|
|
|
|
|
|
|
|
logger = get_custom_logger(__name__)
|
2024-10-11 08:08:39 +00:00
|
|
|
|
2024-06-11 11:36:20 +00:00
|
|
|
|
|
|
|
def pytest_addoption(parser):
|
|
|
|
parser.addoption(
|
2024-10-07 15:40:18 +00:00
|
|
|
"--rpc_url_statusd",
|
2024-06-11 11:36:20 +00:00
|
|
|
action="store",
|
|
|
|
help="",
|
|
|
|
default="http://0.0.0.0:3333",
|
|
|
|
)
|
2024-08-13 12:46:48 +00:00
|
|
|
parser.addoption(
|
2024-10-07 15:40:18 +00:00
|
|
|
"--rpc_url_status_backend",
|
2024-08-13 12:46:48 +00:00
|
|
|
action="store",
|
|
|
|
help="",
|
|
|
|
default="http://0.0.0.0:3334",
|
|
|
|
)
|
2024-09-16 08:23:57 +00:00
|
|
|
parser.addoption(
|
2024-10-07 15:40:18 +00:00
|
|
|
"--ws_url_statusd",
|
2024-09-16 08:23:57 +00:00
|
|
|
action="store",
|
|
|
|
help="",
|
|
|
|
default="ws://0.0.0.0:8354",
|
|
|
|
)
|
2024-10-07 15:40:18 +00:00
|
|
|
parser.addoption(
|
|
|
|
"--ws_url_status_backend",
|
|
|
|
action="store",
|
|
|
|
help="",
|
|
|
|
default="ws://0.0.0.0:3334",
|
|
|
|
)
|
2024-09-25 12:27:04 +00:00
|
|
|
parser.addoption(
|
|
|
|
"--anvil_url",
|
|
|
|
action="store",
|
|
|
|
help="",
|
|
|
|
default="http://0.0.0.0:8545",
|
|
|
|
)
|
2024-06-11 11:36:20 +00:00
|
|
|
parser.addoption(
|
|
|
|
"--password",
|
|
|
|
action="store",
|
|
|
|
help="",
|
|
|
|
default="Strong12345",
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Option:
|
|
|
|
pass
|
|
|
|
|
2024-10-11 08:08:39 +00:00
|
|
|
|
2024-06-11 11:36:20 +00:00
|
|
|
option = Option()
|
|
|
|
|
2024-10-11 08:08:39 +00:00
|
|
|
|
2024-06-11 11:36:20 +00:00
|
|
|
def pytest_configure(config):
|
|
|
|
global option
|
|
|
|
option = config.option
|
|
|
|
option.base_dir = os.path.dirname(os.path.abspath(__file__))
|
2024-10-11 08:08:39 +00:00
|
|
|
|
|
|
|
|
2024-11-11 14:40:05 +00:00
|
|
|
@pytest.fixture(scope="session", autouse=False)
|
2024-10-11 08:08:39 +00:00
|
|
|
def init_status_backend():
|
2024-11-11 14:40:05 +00:00
|
|
|
logger.info(f"Running fixture setup: {inspect.currentframe().f_code.co_name}")
|
2024-10-11 08:08:39 +00:00
|
|
|
|
2024-11-11 14:40:05 +00:00
|
|
|
await_signals = [
|
2024-10-11 08:08:39 +00:00
|
|
|
"mediaserver.started",
|
|
|
|
"node.started",
|
|
|
|
"node.ready",
|
|
|
|
"node.login",
|
|
|
|
"wallet", # TODO: a test per event of a different type
|
|
|
|
]
|
|
|
|
|
2024-11-11 14:40:05 +00:00
|
|
|
from src.node.clients.status_backend import StatusBackend
|
2024-10-11 08:08:39 +00:00
|
|
|
|
2024-11-11 14:40:05 +00:00
|
|
|
backend_client = StatusBackend(await_signals=await_signals)
|
|
|
|
|
|
|
|
websocket_thread = threading.Thread(target=backend_client._connect)
|
2024-10-11 08:08:39 +00:00
|
|
|
websocket_thread.daemon = True
|
|
|
|
websocket_thread.start()
|
|
|
|
|
2024-11-11 14:40:05 +00:00
|
|
|
backend_client.init_status_backend(data_dir="/")
|
2024-10-23 19:48:33 +00:00
|
|
|
backend_client.restore_account_and_wait_for_rpc_client_to_start()
|
2024-10-11 08:08:39 +00:00
|
|
|
|
|
|
|
yield backend_client
|