alphax-polymarket/tests/test_prices.py
2026-05-22 00:38:22 +08:00

35 lines
963 B
Python

from poly_updown.prices import _parse_chainlink_message
def test_parse_chainlink_rtds_message() -> None:
ticks = _parse_chainlink_message(
{
"topic": "crypto_prices",
"type": "update",
"payload": {
"symbol": "btc/usd",
"data": [
{"timestamp": 1779376675000, "value": 77123.45},
{"timestamp": 1779376676000, "value": 77124.45},
],
},
}
)
assert len(ticks) == 2
tick = ticks[-1]
assert tick is not None
assert tick.source == "polymarket_rtds_chainlink"
assert tick.symbol == "btc/usd"
assert tick.price == 77124.45
def test_parse_chainlink_rtds_ignores_other_symbols() -> None:
assert _parse_chainlink_message(
{
"topic": "crypto_prices",
"type": "update",
"payload": {"symbol": "eth/usd", "value": 3000},
}
) == []