Skip to content

Add Rust test suite seeded from bundled samples; fix demo evaluator routing and sample bool encoding#13

Open
aleksUIX wants to merge 1 commit into
IABTechLab:mainfrom
aleksUIX:rust-tests-sample-fixes
Open

Add Rust test suite seeded from bundled samples; fix demo evaluator routing and sample bool encoding#13
aleksUIX wants to merge 1 commit into
IABTechLab:mainfrom
aleksUIX:rust-tests-sample-fixes

Conversation

@aleksUIX

@aleksUIX aleksUIX commented Jul 6, 2026

Copy link
Copy Markdown

Summary

Adds a test suite to the Rust reference implementation, seeded from the bundled samples/*.json payloads. Writing the tests surfaced two existing bugs; both are fixed here.

Bug 1: the demo evaluator never matched any bundled sample

bidder/evaluator.rs matched its auction arms (auction-123, auction-456, ...) against the top-level RTBRequest.id envelope id, but those values are bid_request.id in every sample (the envelope ids are sample-banner-001 etc.). Result: the demo server returned zero mutations for all five bundled samples. The evaluator now routes on the enclosed bid_request.id, consistent with how the Go implementation reads the enclosed BidRequest, and still echoes the envelope id in the response. The unreachable app-123 arm now matches native-ad.json's actual auction id, auction-native-123.

Bug 2: two samples encode proto bool fields as 0/1

multi-impression.json and native-ad.json used 0/1 for device.js, regs.coppa, regs.gdpr, and source.fd, which the proto JSON mapping rejects ("expecting boolean; instead got 1"). This is bug 4 of #11. Both samples now decode cleanly against the schema, which also unblocks sending them to the Go server.

Test coverage

  • rust/src/mutation/builder.rs: unit tests for segment, deal, and bid shade mutation payload shapes, plus metadata versions
  • rust/src/bidder/evaluator.rs: routing table for all five demo auctions, envelope id echo, unknown-auction and missing-bid_request fallbacks
  • rust/src/sample_tests.rs (new): decodes every bundled sample through the compiled proto schema (unknown fields rejected) and asserts each sample drives its documented demo mutations end to end

To support the schema validation tests, build.rs now also emits a file descriptor set to OUT_DIR, and prost-reflect is added as a dev-dependency only. No changes to the committed generated code.

Verification

  • cargo test: 13 passed
  • cargo build produces no diff in the generated proto sources
  • Server boots; /health/live responds OK

…outing

The new tests decode every samples/*.json through the proto schema
(via a descriptor set emitted at build time) and run them through the
demo evaluator. Writing them surfaced two existing bugs, fixed here:

- The evaluator matched auction ids (auction-123, auction-456, ...)
  against the top-level RTBRequest envelope id, so no bundled sample
  ever produced mutations. It now routes on bid_request.id and echoes
  the envelope id in the response, matching the Go implementation's
  use of the enclosed BidRequest. The dead app-123 arm now matches
  native-ad.json's auction-native-123.
- multi-impression.json and native-ad.json encoded proto bool fields
  (device.js, regs.coppa, regs.gdpr, source.fd) as 0/1, which the
  proto JSON mapping rejects. This is bug 4 of IABTechLab#11 (expecting boolean,
  instead got 1); both samples now decode cleanly.

Test coverage added:
- mutation/builder.rs: payload shapes for segments, deals, bid shade
- bidder/evaluator.rs: routing table, envelope id echo, fallbacks
- sample_tests.rs: schema-validates all five samples and asserts each
  drives its documented demo mutations end to end

cargo test: 13 passed. No changes to the generated proto code.
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.

1 participant