Skip to content

Add test coverage for get_pair_info and quote_route defaults at i128 sentinel boundaries #40

Description

@1nonlypiece

Test default sentinels and quote_route net computation

Description

get_pair_info in src/lib.rs returns max_amount: i128::MAX and liquidity: 0 for an unconfigured pair, and quote_route returns (fee, amount - fee) — these specific default-sentinel values and the net subtraction are unverified. The suite asserts get_pair_info only on a fully-configured pair, never on a bare-registered or fully-unconfigured one, and never asserts that quote_route's second tuple element equals amount - fee exactly across fee settings. This issue pins those defaults and the net math.

Requirements and context

  • Repository scope: StableRoute-Org/Stableroute-contracts only.
  • Cover: get_pair_info for (a) a never-touched pair returns registered:false, fee_bps:0, min_amount:0, max_amount:i128::MAX, liquidity:0, last_route_at:0, and (b) a bare-registered pair flips only registered.
  • Cover: quote_route returns net == amount - fee for zero fee, a typical fee, and the MAX_FEE_BPS cap.
  • Cover: quote_route and compute_route_fee agree on the fee value for identical configuration (parity).
  • Use setup_initialized; no production change expected.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/contracts-41-defaults-quote-net-tests
  • Implement changes
    • Write code in: src/lib.rs — no production change expected (open a follow-up if a gap is found).
    • Write comprehensive tests in: src/lib.rs #[cfg(test)] mod test — the defaults + net-math suite described above.
    • Add documentation: note the defaults test matrix in README.md or docs/testing.md.
    • Include NatSpec-style doc comments (///) on any new test helper.
    • Validate security assumptions: default sentinels match doc comments; net is never negative for valid inputs.
  • Test and commit

Test and commit

  • Run cargo fmt --all -- --check, cargo build, and cargo test.
  • Cover edge cases and failure paths: untouched pair, bare-registered pair, zero/typical/max fee net, quote-vs-compute parity.
  • Include the full cargo test output and a short security notes section in the PR description (threat model + mitigations).

Example commit message

test: cover pair-info defaults and quote_route net computation

Guidelines

  • Minimum 95 percent test coverage for impacted modules.
  • Clear, reviewer-focused documentation.
  • Timeframe: 96 hours.

Community & contribution rewards

  • 💬 Join the StableRoute community on Discord for questions, reviews, and faster merges: https://discord.gg/37aCpusvx
  • ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions