test(scanners): add unit tests for ScanResult dataclass and CHAIN_IDS

5 tests covering default values, tier results, timestamp, chain IDs,
and chain count validation.
This commit is contained in:
Crypto Rug Munch 2026-07-08 05:13:52 +02:00
parent 7d3e8b7143
commit 31a6383b5e

View file

@ -0,0 +1,53 @@
from app.domains.scanners.core.models import CHAIN_IDS, ScanResult
class TestScanResult:
def test_default_values(self):
r = ScanResult(token_address="0xabc", chain="ethereum")
assert r.token_address == "0xabc"
assert r.chain == "ethereum"
assert r.symbol == ""
assert r.name == ""
assert r.safety_score == 50
assert r.tier_required == "free"
assert r.confidence == 0
assert r.risk_flags == []
assert isinstance(r.free, dict)
assert isinstance(r.pro, dict)
assert isinstance(r.elite, dict)
def test_tier_results_populated(self):
r = ScanResult(
token_address="0xdef",
chain="solana",
free={"basic": "ok"},
pro={"advanced": "ok"},
elite={"full": "ok"},
safety_score=80,
risk_flags=["possible_clone"],
modules_run=[{"module": "clone_check", "status": "passed"}],
)
assert r.free["basic"] == "ok"
assert r.pro["advanced"] == "ok"
assert r.elite["full"] == "ok"
assert r.safety_score == 80
assert "possible_clone" in r.risk_flags
assert len(r.modules_run) == 1
def test_scanned_at_is_set(self):
r = ScanResult(token_address="0xghi", chain="polygon")
assert r.scanned_at is not None
assert "T" in r.scanned_at
class TestChainIds:
def test_known_chains(self):
assert CHAIN_IDS["solana"] == "solana"
assert CHAIN_IDS["ethereum"] == "1"
assert CHAIN_IDS["base"] == "8453"
assert CHAIN_IDS["bsc"] == "56"
def test_chain_count(self):
assert len(CHAIN_IDS) >= 12