Skip to content

test(ws): live ticker data assertion on high-traffic channel (Closes #181) - #182

Merged
martinkersner merged 3 commits into
mainfrom
issue-181-live-ws-high-traffic
Jul 6, 2026
Merged

test(ws): live ticker data assertion on high-traffic channel (Closes #181)#182
martinkersner merged 3 commits into
mainfrom
issue-181-live-ws-high-traffic

Conversation

@martinkersner

@martinkersner martinkersner commented Jul 6, 2026

Copy link
Copy Markdown
Member

Closes #181

Summary

The live WS lane only covered sporadic channels (/liquidation, /announcement/listing) where a quiet window (no event before timeout) is a pass — that verifies connect + auth + SUBSCRIBE but never proves the SDK decodes and yields a real payload. This PR adds coverage across more channels, choosing the test type per channel's real cadence (probed live):

High-traffic → HARD data-assertion (silence = FAIL):

  • ticker spot (BTC-USDT@binance) — asserts msg["s"]=="BTC-USDT", "p" in msg within 30s.
  • ticker futures (BTC-USDT@binance, market="futures") — same, plus msg["m"]=="futures" to prove the futures path (not spot) is exercised.
  • premium (binance:upbit:bitcoin:USDT:KRW:spot:spot, 24/7) — asserts msg["key"]==..., "premium" in msg within 30s (the premium value is nullable, so identity fields are asserted, not the value).

Sporadic → quiet-window TOLERANT (silence = PASS) + shape-check-if-present:

  • forex (USD-KRW) — 20s bound (first tick can lag ~14s; FX spot is quiet on weekends/off-hours). If a tick arrives: msg["s"]=="USD-KRW", "r" in msg.
  • funding_rate (BTC-USDT@binance) — on-change/snapshot, sporadic. If a msg arrives: non-empty data dict (shape not observable live).
  • open_interest (BTC-USDT@binance) — sporadic. Same minimal shape check.

Quiet-tolerant tests mirror the existing test_ws_liquidation_... structure (TimeoutError → PASS). Acks are filtered by the client reader, so the first yielded message is always a real payload. Additive: new test fns + _DATA_TIMEOUT/_FOREX_TIMEOUT constants + widened module docstring; existing tests untouched. All under the integration marker (needs DATAMAXI_API_KEY), deselected from the keyless lane, consistent with the non-blocking (continue-on-error) live lane.

Test plan

  • DATAMAXI_API_KEY=... pytest tests/test_ws_live.py -v -m integration8 passed (ticker spot/futures + premium receive real data; forex/funding/OI pass via quiet window or shape-check).
  • pytest tests/ -m "not integration" → 226 passed, all live tests deselected (115 deselected).
  • black + flake8 clean.

Sporadic-channel live tests treat a quiet window as pass. Add ticker
(BTC-USDT@binance spot) test asserting a real data msg (s==BTC-USDT, has p)
arrives within 30s; quiet window is a FAIL. Proves SDK decodes+yields payload
end-to-end. integration marker, needs DATAMAXI_API_KEY.
@martinkersner martinkersner self-assigned this Jul 6, 2026
…lanes

premium high-traffic (24/7) -> hard data-assert (key match, premium field
present; value nullable so not asserted). forex/funding-rate/open-interest
sporadic -> quiet window=PASS, shape-checked when a msg arrives (forex s/r;
funding/OI non-empty dict, shape not observable live). Widen module docstring.
Futures sibling of the spot ticker test; high-traffic -> silence=FAIL.
Asserts s==BTC-USDT, has p, and m==futures to prove the futures path.
@martinkersner
martinkersner merged commit 366f14a into main Jul 6, 2026
5 checks passed
@martinkersner
martinkersner deleted the issue-181-live-ws-high-traffic branch July 6, 2026 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add live WS test asserting real data on a high-traffic channel

1 participant