"""Free tests: no wallet, nothing paid. Run with `python -m pytest -q`."""

import pytest

from langchain_egg_verify import (
    EggVerifyClaimTool, EggVerifyClient, EggVerifyError, get_egg_verify_tools,
)


def test_service_card_lists_endpoints():
    card = EggVerifyClient().service_card()
    assert "POST /verify" in card["endpoints"]


def test_quote_reads_402_without_paying():
    opt = EggVerifyClient().quote("verify", {"claim": "x", "url": "https://example.com"})
    assert int(opt["amount"]) == 50_000  # $0.05
    assert opt["network"] == "eip155:8453"


def test_tools_have_schemas():
    names = [t.name for t in get_egg_verify_tools(EggVerifyClient())]
    assert names == ["egg_service_card", "egg_verify_claim", "egg_scout", "egg_deepdive"]
    assert set(EggVerifyClaimTool(client=EggVerifyClient()).args) == {"claim", "url"}


def test_cap_blocks_expensive_endpoints_before_signing():
    c = EggVerifyClient(private_key="0x" + "11" * 32)  # throwaway, unfunded
    with pytest.raises(EggVerifyError, match="above the per-call cap"):
        c.scout("anything", ["https://example.com"])


def test_paid_call_needs_key(monkeypatch):
    monkeypatch.delenv("AGENT_PRIVATE_KEY", raising=False)
    with pytest.raises(EggVerifyError, match="AGENT_PRIVATE_KEY"):
        EggVerifyClient().verify("x", "https://example.com")
