mirror of
https://github.com/vibe-existing/pyfragment.git
synced 2026-07-25 06:54:31 +00:00
efcdda6b74
- Migrate from tonutils 0.5.x to 2.0.0 API: - ToncenterClient → TonapiClient with NetworkGlobalID - tonutils.client → tonutils.clients - tonutils.wallet → tonutils.contracts.wallet - pub_key.as_hex property, wallet.balance nanotons - async with client context manager - Centralize TON client init into initialize_ton_client() in wallet.py - Move process_transaction logic into wallet.py, transaction.py re-exports - Add WALLET_VERSION config (V4R2/V5R1, default V5R1) - Add WALLET_CLASSES and SUPPORTED_WALLET_VERSIONS to constants.py - Restore balance check before broadcasting - Wait for seqno confirmation after transfer (120×2s) to prevent duplicate seqno - Fix Fragment hash fetching: use browser navigation headers - Remove accept-encoding from BASE_HEADERS (httpx handles decompression) - Add cookies.example.json template - Add cookies.json to .gitignore
18 lines
574 B
Python
18 lines
574 B
Python
"""Tests for get_fragment_hash() — fetches a valid lowercase hex hash
|
|
from the fragment.com/stars/buy page source."""
|
|
|
|
import re
|
|
|
|
import pytest
|
|
|
|
from app.core.constants import BASE_HEADERS, STARS_PAGE
|
|
from app.utils.hash import get_fragment_hash
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_hash_is_valid_hex(cookies: dict) -> None:
|
|
result = await get_fragment_hash(cookies, BASE_HEADERS, STARS_PAGE)
|
|
assert isinstance(result, str)
|
|
assert len(result) >= 10, f"hash too short: {result!r}"
|
|
assert re.fullmatch(r"[a-f0-9]+", result), f"not a hex string: {result!r}"
|