Skip to content

Add test coverage for the version and get_schema_version distinction and NotInitialized paths #48

Description

@mikewheeleer

Test the version surface and uninitialized-call failures

Description

src/lib.rs exposes two distinct version concepts — version() returning the symbol ROUTER_V2 and get_schema_version() returning the storage schema number — and a class of NotInitialized (#2) failures when admin-gated entrypoints are called before init. The existing suite checks version() once and the happy-path migration, but never asserts that admin entrypoints (pause, set_pair_fee_bps, propose_admin_transfer, migrate_v1_to_v2, etc.) panic with #2 on a fresh, uninitialized contract. This issue adds that coverage.

Requirements and context

  • Repository scope: StableRoute-Org/Stableroute-contracts only.
  • Cover: version() is stable (ROUTER_V2) and independent of get_schema_version().
  • Cover: on a contract registered but NOT init-ed, each admin-gated entrypoint panics with NotInitialized (Bump persistent-entry TTL on every router storage read and write to prevent state expiry #2) — use #[should_panic(expected = "Error(Contract, #2)")].
  • Cover: get_schema_version returns 1 before any init/migration (default fallback).
  • Register the contract WITHOUT calling init for the negative cases (do not reuse setup_initialized).

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/contracts-40-version-uninitialized-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 version + NotInitialized suite described above.
    • Add documentation: note the lifecycle test matrix in README.md or docs/testing.md.
    • Include NatSpec-style doc comments (///) on any new test helper.
    • Validate security assumptions: no admin entrypoint succeeds before initialization; the two version concepts are clearly separated.
  • Test and commit

Test and commit

  • Run cargo fmt --all -- --check, cargo build, and cargo test.
  • Cover edge cases and failure paths: uninitialized pause/fee/transfer/migrate, schema-version default, version constant.
  • Include the full cargo test output and a short security notes section in the PR description (threat model + mitigations).

Example commit message

test: cover version surface and uninitialized-call NotInitialized paths

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 fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions