Give every round its own pool address (B-80, RND-35, DAT-60, DAT-11, REG-14, SEC-08, BET-12, RND-22, WDR-14, SEC-43, API-23, API-36)
2026-10-14 13:52:32 +02:00
|
|
|
"""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
|
2026-10-14 15:45:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# B-74: the real powLimit needs ~2^32 hashes per header, so tests mine headers at a trivial
|
|
|
|
|
# target (`0x207fffff`) and this swaps in a limit that allows it. Done at import, not in a
|
|
|
|
|
# fixture, because some test modules mine headers while they are being collected. The
|
|
|
|
|
# tests that exercise the limit itself put `MAINNET_POW_LIMIT` back with monkeypatch.
|
|
|
|
|
from app.rounds import draw as _draw # noqa: E402
|
|
|
|
|
|
|
|
|
|
_draw.POW_LIMIT = (1 << 256) - 1
|