test(news,scanner,wsh): builders + body-verifying test migration#501
Merged
Conversation
PR 6 of the test-builder rollout.
- Add request builders in src/testdata/builders/{news,scanner,wsh}.rs;
contract_news/broad_tape_news reuse MarketDataRequestBuilder.
- Migrate sync/async tests to assert_request<B>(builder); move inline
mod tests blocks to sibling _tests.rs files.
- Drop self-loop encoder tests in {news,scanner,wsh}/common/encoders.rs
and the inline wsh/mod.rs::common_tests encoder asserts.
- Remove dead MessageBus/AsyncMessageBus::request_messages trait
methods (only consumers were the migrated sync tests, which now
call MessageBusStub::request_messages directly).
- Rename cancel_by_request_id_builder! to single_req_id_request_builder!. The macro is reused for non-cancel single-req_id requests (WshMetaDataRequest), mirroring production's encode_cancel_by_id!. - HistoricalNewsRequestBuilder::default contract_id is now TEST_CONTRACT_ID (was 0, encoded as Some(0) in tests that forget to override). - Drop dead _silence helper + unused request_message_count import in wsh/sync_tests.rs. - Drop redundant path attribute in wsh/mod.rs common_tests declaration.
- Replace magic 8314 contract id with TEST_CONTRACT_ID; lets the builder use its default and drops a redundant .contract_id() setter. - Extract repeated 84|9000|... news article response literal to a file-local NEWS_ARTICLE_RESPONSE const (5 callsites).
wboayue
added a commit
that referenced
this pull request
May 3, 2026
- test-builders.md: PRs #495-#501 merged. - issue-441-order-status-option-doubles.md: issue closed; OrderStatus fields are now Option<f64>. - issue-434-stream-decoder-error-handling.md: issue closed; main fixed via #490 (v2-stable mirror is a separate concern if it surfaces). - improve-encoder-test-coverage.md: approach superseded by the test-builders pattern (assert_request<B>(builder) at the integration layer in place of field-level encoder unit tests). Merged commits preserve the history.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR 6 of the test-builder rollout (see
todos/test-builders.md).src/testdata/builders/{news,scanner,wsh}.rs.contract_news/broad_tape_newsreuseMarketDataRequestBuildersince they fan out throughencode_request_market_data.assert_request<B>(builder)body verification. Move inlinemod testsblocks to flat sibling_tests.rsfiles (news/{sync,async}_tests.rs,scanner/{sync,async}_tests.rs,wsh/{sync,async}_tests.rs,wsh/common_tests.rs).{news,scanner,wsh}/common/encoders.rsand the inlinewsh::common_testsencoder asserts.MessageBus::request_messagesandAsyncMessageBus::request_messagestrait methods (and theirMessageBusStubimpls). The only consumers were the migrated sync tests, which now use the inherentMessageBusStub::request_messagesviaassert_request<B>(&message_bus, …).Test plan
cargo fmtcargo clippy --all-targets -- -D warningscargo clippy --all-targets --features sync -- -D warningscargo clippy --all-featurescargo test --features sync --lib— 1088 passedcargo test --features async --lib— 901 passedcargo test --all-features --lib— 1089 passed