"""Shared fixtures and canned API responses for tests."""

from unittest.mock import MagicMock

import pytest

from boxtime.clients.ergo_node_client import ErgoNodeClient

# ------------------------------------------------------------------
# Canned API responses
# ------------------------------------------------------------------

EMISSION_JSON = {
    "minerReward": 67500000000,
    "totalCoinsIssued": 50_000_000_000_000_000,
    "totalRemainCoins": 47_284_800_000_000_000,
    "reemitted": 0,
}

BLOCK_HEADER_JSON = {
    "id": "header123",
    "timestamp": 1700000000000,
    "version": 3,
    "adProofsRoot": "abc",
    "stateRoot": "def",
    "transactionsRoot": "ghi",
    "nBits": 117440512,
    "extensionHash": "jkl",
    "powSolutions": {
        "pk": "pk123",
        "w": "w123",
        "n": "n123",
        "d": "0",
    },
    "height": 1000,
    "difficulty": "123456",
    "parentId": "parent123",
    "votes": "000000",
}

ERGO_BOX_JSON = {
    "boxId": "box123",
    "value": 1_000_000_000,
    "ergoTree": "0008cd...",
    "creationHeight": 900,
    "assets": [],
    "additionalRegisters": {},
    "transactionId": "tx123",
    "index": 0,
    "address": "9f...",
    "inclusionHeight": 950,
    "globalIndex": 42,
}

TRANSACTION_JSON = {
    "id": "tx123",
    "inputs": [
        {
            "boxId": "inbox1",
            "value": 500_000_000,
            "ergoTree": "0008cd...",
            "creationHeight": 800,
            "assets": [],
            "additionalRegisters": {},
            "inclusionHeight": 900,
            "globalIndex": 10,
        },
    ],
    "dataInputs": [],
    "outputs": [
        {
            "boxId": "outbox1",
            "value": 500_000_000,
            "ergoTree": "0008cd...",
            "creationHeight": 1000,
            "assets": [],
            "additionalRegisters": {},
            "index": 0,
        },
    ],
    "inclusionHeight": 1000,
    "numConfirmations": 100,
    "blockId": "block123",
    "timestamp": 1700000000000,
    "index": 0,
    "globalIndex": 5000,
    "size": 300,
}


# ------------------------------------------------------------------
# Fixtures
# ------------------------------------------------------------------


@pytest.fixture
def mock_session():
    """A MagicMock standing in for aiohttp.ClientSession."""
    return MagicMock()


@pytest.fixture
def ergo_client(mock_session):
    """An ErgoNodeClient bound to a mock session."""
    return ErgoNodeClient(mock_session, "http://test:9053")
