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
|
|
|
|
2022-04-26 17:18:41 +02:00
|
|
|
def pytest_addoption(parser):
|
2022-06-28 10:37:07 +02:00
|
|
|
# nanos, nanox, nanosp
|
2022-04-26 17:18:41 +02:00
|
|
|
parser.addoption("--model", action="store", default="nanos")
|
|
|
|
|
# qt: default, requires a X server
|
|
|
|
|
# headless: nothing is displayed
|
|
|
|
|
parser.addoption("--display", action="store", default="qt")
|
|
|
|
|
|
2022-06-28 10:37:07 +02:00
|
|
|
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()
|
2022-04-26 17:18:41 +02:00
|
|
|
def client(pytestconfig):
|
2022-06-28 10:37:07 +02:00
|
|
|
file_path = pytestconfig.getoption("path")
|
2022-04-26 17:18:41 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
2022-04-26 17:18:41 +02:00
|
|
|
@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,
|
2022-04-26 17:18:41 +02:00
|
|
|
debug=True,
|
|
|
|
|
model=pytestconfig.getoption("model"),
|
2022-04-08 09:57:12 +02:00
|
|
|
)
|