Skip to content

reader::get_position_info — the primary position-detail query — has zero test coverage #596

Description

@abayomicornelius

Problem

reader::get_position_info (contracts/reader/src/lib.rs:422-...) has zero test coverage anywhere in the repository:

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

This is the richest position-detail query in the contract — it resolves the position from order_handler, computes PnL (get_position_pnl_usd) and fees (get_position_fees) via oracle prices, and as a side effect calls OrderHandlerClient::bump_position_ttl to keep the position's storage alive. None of that — the PnL calculation, the fee breakdown, or the TTL bump side effect — is exercised by any test. (get_position_info_by_key, a sibling function taking a raw key instead of the four position-identifying parameters, does have test coverage — this asymmetry means the more commonly-used four-parameter entry point is the untested one.)

Why it matters

This is very likely the primary RPC a frontend calls to render a user's open position (PnL, fees owed, size). A regression in the PnL sign, the fee-in-collateral-token conversion, or the TTL bump silently failing would show a trader an incorrect position value with no test to catch it.

Suggested fix

Add a test that opens a position, sets known prices, and calls get_position_info directly (not just get_position_info_by_key), asserting the returned PnL and fees match the values independently computed by the position/fee test helpers used elsewhere in the suite.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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