Files
plm-lottery/tests/unit/conftest.py
T

25 lines
997 B
Python
Raw Normal View History

"""Every test runs against a throwaway master key, never the operator's real one.
B-80: opening a round now derives its pool address, so code paths that merely open a
round (the scheduler, `POST /bets`, the round route) need a master key — and without
this they silently read whatever `MASTER_KEY_PATH`/`XPRV_ENCRYPTION_KEY` of the local
`.env` point at, i.e. the real encrypted key on a developer machine and nothing at all
on a clean checkout. Tests that build their own key (most of them) simply override it.
"""
import pytest
from cryptography.fernet import Fernet
from app.config import settings
@pytest.fixture(autouse=True)
def _throwaway_master_key(tmp_path, monkeypatch):
monkeypatch.setattr(settings, "master_key_path", str(tmp_path / "autouse-master.xprv.enc"))
monkeypatch.setattr(settings, "xprv_encryption_key", Fernet.generate_key().decode())
from app.wallet import hd
hd._account_key = None
hd.generate_master_key()
yield
hd._account_key = None