Skip to content

test(ws): assert real data on /liquidation/feed live test#202

Merged
martinkersner merged 2 commits into
mainfrom
issue-201-ws-assert-real-data-on
Jul 10, 2026
Merged

test(ws): assert real data on /liquidation/feed live test#202
martinkersner merged 2 commits into
mainfrom
issue-201-ws-assert-real-data-on

Conversation

@martinkersner

@martinkersner martinkersner commented Jul 10, 2026

Copy link
Copy Markdown
Member

Closes #201

Summary

Adds a data-asserting live WS test for liquidation_feed (/ws/v1/liquidation/feed) to tests/test_ws_live.py, in the guaranteed-data group alongside ticker/premium where a quiet window is a FAIL, not a pass. The channel had no live test before because a fresh connection wasn't guaranteed to yield data within a bounded window.

Backend Bisonai/datamaxi-backend#7990 (PR #8338, merged 976b264f5) now replays the last N liquidations immediately on connect (each replayed frame tagged snap: true; live frames omit it via omitempty). A fresh connection is therefore deterministic and assertable end-to-end.

The channel is connect-only (no SUBSCRIBE, no params) — the test drives ws.liquidation_feed.stream().

Also closes #185 (which asked for any live-lane coverage of this channel; this delivers the hard data-assert directly).

Design notes

  • snap assertion: the backend subscribes before replaying, so a live event may interleave and the first frame is not guaranteed to be a replay frame. The test collects the first few frames (up to N=5, stopping early on timeout) and asserts snap: true on at least one of them, rather than frame[0].snap. This couples the test to replay being enabled: with LIQUIDATION_FEED_REPLAY_N=0 in the target env it FAILs rather than skips — deliberately, to catch an accidentally-disabled replay.
  • Short timeout: replay lands within the handshake, so a dedicated _REPLAY_TIMEOUT = 10.0 is used (not _QUIET_TIMEOUT); a quiet window is a FAIL.
  • Shape: asserts e, d, s, b, q, sd present and d is a plausible UNIX-ms timestamp.
  • Module docstring updated so /liquidation/feed sits in the guaranteed-data (FAIL-on-quiet) group.

Test plan

  • flake8 + black --check on the changed file: clean.
  • Offline suite pytest -m "not integration": 236 passed, 11 skipped, 116 deselected.
  • Live lane run against production (https://api.datamaxiplus.com): the new test passes in ~1.3s, and the full tests/test_ws_live.py integration set is 9 passed. Frames arrived carrying snap: true, confirming replay-on-connect is live.

Deploy gate: cleared

An earlier revision of this body warned against merging until a data-api deploy carrying 976b264f5 was live. Verified on the wire: production returns snap: true replay frames on connect, so the gate no longer applies.

backend now replays last N liquidations on connect (snap:true), so a
fresh connection deterministically yields data — assert it like ticker,
quiet window is a FAIL. Close #201.
@martinkersner martinkersner self-assigned this Jul 10, 2026
@martinkersner
martinkersner merged commit 4415921 into main Jul 10, 2026
5 checks passed
@martinkersner
martinkersner deleted the issue-201-ws-assert-real-data-on branch July 10, 2026 02:58
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.

ws: assert real data on /liquidation/feed live test (backend now replays last N on connect) Add live WS test for liquidation/feed (firehose)

1 participant