"""Shared test fixtures for SooSeF tests."""

from __future__ import annotations

from pathlib import Path

import pytest
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey


@pytest.fixture()
def tmp_soosef_dir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
    """Set SOOSEF_DATA_DIR to a temporary directory.

    This must be used before importing any module that reads soosef.paths
    at import time. For modules that read paths lazily (most of them),
    monkeypatching the paths module directly is more reliable.
    """
    data_dir = tmp_path / ".soosef"
    data_dir.mkdir()
    monkeypatch.setenv("SOOSEF_DATA_DIR", str(data_dir))
    return data_dir


@pytest.fixture()
def chain_dir(tmp_path: Path) -> Path:
    """A temporary chain directory."""
    d = tmp_path / "chain"
    d.mkdir()
    return d


@pytest.fixture()
def private_key() -> Ed25519PrivateKey:
    """A fresh Ed25519 private key for testing."""
    return Ed25519PrivateKey.generate()
