Files
app-ethereum/tests/speculos/conftest.py

40 lines
1.1 KiB
Python
Raw Normal View History

2022-04-08 09:57:12 +02:00
from pathlib import Path
import pytest
from speculos.client import SpeculosClient
2022-06-06 10:16:32 +02:00
from ethereum_client.ethereum_cmd import EthereumCommand
2022-04-08 09:57:12 +02:00
SCRIPT_DIR = Path(__file__).absolute().parent
API_URL = "http://127.0.0.1:5000"
2022-06-23 10:32:41 +02:00
def pytest_addoption(parser):
# nanos, nanox, nanosp
parser.addoption("--model", action="store", default="nanos")
# qt: default, requires a X server
# headless: nothing is displayed
parser.addoption("--display", action="store", default="qt")
path: str = SCRIPT_DIR.parent.parent / "bin" / "app.elf"
parser.addoption("--path", action="store", default=path)
2022-07-22 10:59:24 +02:00
@pytest.fixture()
def client(pytestconfig):
file_path = pytestconfig.getoption("path")
model = pytestconfig.getoption("model")
2023-02-20 16:49:02 +01:00
args = ['--log-level', 'speculos:DEBUG','--model', model, '--display', pytestconfig.getoption("display")]
2022-04-08 09:57:12 +02:00
with SpeculosClient(app=str(file_path), args=args) as client:
yield client
@pytest.fixture()
def cmd(client, pytestconfig):
2022-06-06 10:16:32 +02:00
yield EthereumCommand(
2022-04-08 09:57:12 +02:00
client=client,
debug=True,
model=pytestconfig.getoption("model"),
2022-04-08 09:57:12 +02:00
)