SIGN IN SIGN UP

market_data/historical/async: lift coverage 83.75% → 92.06% (#563)

* market_data/historical/async: lift coverage 83.75% → 92.06%

Add 18 tests covering version gates (head_timestamp, schedule + trading-class
arm, ticks_{bid_ask,mid_point,trade}, cancel_historical_ticks, histogram_data,
streaming trading-class arm), decoder branches (head_timestamp + schedule
unexpected-response, historical_data HISTORICAL_DATA_END follow-on, MAX_RETRIES
exhaustion → ConnectionReset), and TickSubscription edge cases (cancel happy
path + idempotency, fill_buffer wrong-type skip, Some(Err) via injected
RoutedItem::Error, closed-channel None).

* historical/async_tests: fold version-check duplication, sweep contract literals

Extract assert_version_check_fails helper — collapses 9 repeated version-check
test bodies (and 3 mismatched assertion shapes: expect_err / let-else /
is_err) into a single closure-based helper. Sidesteps the T: Debug bound that
blocks .expect_err() on TickSubscription / Subscription return types.

Sweep 11 inline GBL/EUREX/EUR contract literals in pre-existing tests to use
test_contract(). Net −104 lines, coverage unchanged (92.06%).

* /simplify: type version-check helper, extract unexpected-response helper, fix bare matches!

- Change assert_version_check_fails to take ProtocolFeature; derive
  min_version - 1 + feature.name internally. Removes 9 stringly-typed
  literal pairs (rule 21).
- Extract assert_unexpected_response, fold 3 sites (incl. pre-existing
  test_historical_data_unexpected_response per rule 9). The pre-existing
  test had a bare `matches!(...)` statement — bool discarded, variant
  check silently dropped. Helper centralizes `assert!(matches!(...))`.
- Two new tests had the same matches! bug; now fixed via the helper.
- Hoist `use ...RoutedItem` from inside a test to top-level imports.
- Drop `///` rustdoc on private helpers (`//` is enough).
- Replace 4 hand-rolled `MessageBusStub { ... }` literals with `with_responses`.
- Trim narrating "WHAT" comments per project style.

Coverage unchanged at 92.06%. Net −19 lines.
W
Wil Boayue committed
86c8aa91265ad04033c1865ace0227e24ffae28a
Parent: f754923
Committed by GitHub <noreply@github.com> on 5/12/2026, 5:51:25 AM