Skip to content

Add test coverage that the upgrade entrypoint is admin-gated and emits the upgraded event even while paused #132

Description

@mikewheeleer

Test the upgrade auth gate and its deliberate paused-state exception

Description

upgrade in src/lib.rs is admin-gated, emits an upgraded event with the new WASM hash, and deliberately skips the pause gate so a paused router can still be patched. The doc comment reasons about this trade-off, but there is no test asserting (a) a non-admin caller is rejected and (b) an upgrade still proceeds and emits its event while the router is paused. This issue adds that coverage, including a real round-trip upgrade to a second WASM that preserves pair state.

Requirements and context

  • Repository scope: StableRoute-Org/Stableroute-contracts only.
  • Assert a non-admin caller cannot call upgrade.
  • Assert the upgraded event is emitted carrying the new hash.
  • Assert an upgrade succeeds while is_paused() is true (the documented exception).
  • Use the Soroban test util pattern for registering a second contract WASM / hash so the upgrade actually swaps code and pair registrations survive.
  • Distinct from the issues-1 "add a contract upgrade entrypoint" feature item — that builds upgrade; this issue verifies its auth and paused-exception behaviour.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/contracts-upgrade-auth-and-paused-coverage
  • Implement changes
    • Write code in: src/lib.rs — no production change expected.
    • Write comprehensive tests in: src/lib.rs (inline #[cfg(test)] mod test) — cover non-admin rejection, the upgraded event, the paused-state exception, and state survival across the upgrade.
    • Add documentation: none required beyond test doc comments.
    • Include NatSpec-style doc comments (///) on each new test, matching the existing style in lib.rs.
    • Validate security assumptions: only admin upgrades; paused exception does not become an escalation path.
  • Test and commit

Test and commit

  • Run cargo fmt --all -- --check, cargo build, and cargo test.
  • Cover edge cases: non-admin rejection, event emission, upgrade while paused, and pair state preserved post-upgrade.
  • Include the full cargo test output in the PR description.

Example commit message

test: cover upgrade admin gating, upgraded event, and paused-state exception

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

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions