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.
Test default sentinels and quote_route net computation
Description
get_pair_infoinsrc/lib.rsreturnsmax_amount: i128::MAXandliquidity: 0for an unconfigured pair, andquote_routereturns(fee, amount - fee)— these specific default-sentinel values and the net subtraction are unverified. The suite assertsget_pair_infoonly on a fully-configured pair, never on a bare-registered or fully-unconfigured one, and never asserts thatquote_route's second tuple element equalsamount - feeexactly across fee settings. This issue pins those defaults and the net math.Requirements and context
get_pair_infofor (a) a never-touched pair returnsregistered:false, fee_bps:0, min_amount:0, max_amount:i128::MAX, liquidity:0, last_route_at:0, and (b) a bare-registered pair flips onlyregistered.quote_routereturnsnet == amount - feefor zero fee, a typical fee, and theMAX_FEE_BPScap.quote_routeandcompute_route_feeagree on the fee value for identical configuration (parity).setup_initialized; no production change expected.Suggested execution
git checkout -b test/contracts-41-defaults-quote-net-testssrc/lib.rs— no production change expected (open a follow-up if a gap is found).src/lib.rs#[cfg(test)] mod test— the defaults + net-math suite described above.README.mdordocs/testing.md.///) on any new test helper.Test and commit
cargo fmt --all -- --check,cargo build, andcargo test.cargo testoutput 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 computationGuidelines
Community & contribution rewards