Test the routing side effects of compute_route_fee
Description
compute_route_fee in src/lib.rs has four side effects on a successful call: it increments TotalRoutesAllTime, stamps PairLastRouteAt, and publishes the route event with (source, destination, amount). The existing tests check the returned fee and the counter once, but never assert the route event payload, never verify the timestamp is stamped from a non-zero env.ledger().set_timestamp, and never confirm the counter is shared across multiple distinct pairs. This issue adds focused coverage of the mutation surface.
Requirements and context
- Repository scope: StableRoute-Org/Stableroute-contracts only.
- Cover:
route event topic route and data (source, destination, amount) via env.events().all().
- Cover:
PairLastRouteAt reflects a custom env.ledger().set_timestamp value after a route, and is None before.
- Cover:
TotalRoutesAllTime increments once per route and is global across two different pairs.
- Cover:
quote_route does NOT emit a route event nor change the counter (parity guard) — assert event count unchanged.
Suggested execution
- Fork the repo and create a branch
git checkout -b test/contracts-39-route-side-effect-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 side-effect suite described above.
- Add documentation: note the routing side-effect test matrix in
README.md or docs/testing.md.
- Include NatSpec-style doc comments (
///) on any new test helper.
- Validate security assumptions: every documented side effect is asserted;
quote_route proven non-mutating.
- Test and commit
Test and commit
- Run
cargo fmt --all -- --check, cargo build, and cargo test.
- Cover edge cases and failure paths: event payload, timestamp before/after, global counter across pairs, quote non-mutation.
- Include the full
cargo test output and a short security notes section in the PR description (threat model + mitigations).
Example commit message
test: cover compute_route_fee counter, timestamp, and route event
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 the routing side effects of compute_route_fee
Description
compute_route_feeinsrc/lib.rshas four side effects on a successful call: it incrementsTotalRoutesAllTime, stampsPairLastRouteAt, and publishes therouteevent with(source, destination, amount). The existing tests check the returned fee and the counter once, but never assert therouteevent payload, never verify the timestamp is stamped from a non-zeroenv.ledger().set_timestamp, and never confirm the counter is shared across multiple distinct pairs. This issue adds focused coverage of the mutation surface.Requirements and context
routeevent topicrouteand data(source, destination, amount)viaenv.events().all().PairLastRouteAtreflects a customenv.ledger().set_timestampvalue after a route, and isNonebefore.TotalRoutesAllTimeincrements once per route and is global across two different pairs.quote_routedoes NOT emit arouteevent nor change the counter (parity guard) — assert event count unchanged.Suggested execution
git checkout -b test/contracts-39-route-side-effect-testssrc/lib.rs— no production change expected (open a follow-up if a gap is found).src/lib.rs#[cfg(test)] mod test— the side-effect suite described above.README.mdordocs/testing.md.///) on any new test helper.quote_routeproven non-mutating.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 compute_route_fee counter, timestamp, and route eventGuidelines
Community & contribution rewards