Test pair lifecycle events and idempotency edges
Description
The existing suite in src/lib.rs covers basic register/unregister round-trips, but it never asserts the emitted events for the pair lifecycle (pair_reg, unreg, fee_set, liq_set, init) and never verifies edge behaviors like unregistering a never-registered pair, re-registering after unregister, or that unregister_pair leaves the configured fee untouched (the behavior its own doc comment claims). This issue adds event-assertion and lifecycle-edge coverage.
Requirements and context
- Repository scope: StableRoute-Org/Stableroute-contracts only.
- Use
env.events().all() to assert the topic and data tuple emitted by init, register_pair, unregister_pair, set_pair_fee_bps, and set_pair_liquidity.
- Cover: unregister of a never-registered pair is a clean no-op, re-register after unregister works, and
unregister_pair does NOT clear PairFeeBps (documenting the current behavior precisely).
- Use the existing
setup_initialized helper; no production change expected unless a discrepancy is found.
- Assert exact event counts so a future extra/missing publish is caught.
Suggested execution
- Fork the repo and create a branch
git checkout -b test/contracts-38-pair-lifecycle-event-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 event-assertion and lifecycle-edge suite described above.
- Add documentation: note the pair-lifecycle test matrix in
README.md or docs/testing.md.
- Include NatSpec-style doc comments (
///) on any new test helper.
- Validate security assumptions: events are emitted exactly once per state change with the documented payload.
- Test and commit
Test and commit
- Run
cargo fmt --all -- --check, cargo build, and cargo test.
- Cover edge cases and failure paths: event topic/data per entrypoint, no-op unregister, re-register, fee survives unregister.
- 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 lifecycle events and idempotency edges
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 pair lifecycle events and idempotency edges
Description
The existing suite in
src/lib.rscovers basic register/unregister round-trips, but it never asserts the emitted events for the pair lifecycle (pair_reg,unreg,fee_set,liq_set,init) and never verifies edge behaviors like unregistering a never-registered pair, re-registering after unregister, or thatunregister_pairleaves the configured fee untouched (the behavior its own doc comment claims). This issue adds event-assertion and lifecycle-edge coverage.Requirements and context
env.events().all()to assert the topic and data tuple emitted byinit,register_pair,unregister_pair,set_pair_fee_bps, andset_pair_liquidity.unregister_pairdoes NOT clearPairFeeBps(documenting the current behavior precisely).setup_initializedhelper; no production change expected unless a discrepancy is found.Suggested execution
git checkout -b test/contracts-38-pair-lifecycle-event-testssrc/lib.rs— no production change expected (open a follow-up if a gap is found).src/lib.rs#[cfg(test)] mod test— the event-assertion and lifecycle-edge 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 lifecycle events and idempotency edgesGuidelines
Community & contribution rewards