Skip to content

reader::get_execution_price_preview has zero test coverage #597

Description

@abayomicornelius

Problem

reader::get_execution_price_preview (contracts/reader/src/lib.rs:594-624) has zero test coverage anywhere in the repository:

grep -rn "get_execution_price_preview" --include="*.rs" . | grep -v reader/src/lib.rs
# no output

It composes two other library calls — get_position_price_impact and get_execution_price — to preview the execution price a trader would receive for a given size/direction before submitting an order. Neither the price-impact computation nor the final execution-price composition is verified through this entry point by any test.

Why it matters

This is explicitly a UI-facing slippage preview ("Useful for the UI to preview slippage before placing an order," per its own doc comment). If the preview diverges from what order_handler::execute_order actually charges (e.g. because one uses mid_price() and the other doesn't, or a future change to get_position_price_impact's signature isn't mirrored here), users would be shown a systematically wrong price with no test to catch the drift.

Suggested fix

Add a test that computes get_execution_price_preview for a known market/size/direction and cross-checks the result against the actual price impact/execution price a real MarketIncrease/MarketDecrease order pays in order_handler's own tests for equivalent inputs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions