feat(revenue_pool): add per-entrypoint auth snapshot test for #888 - #976
Open
Dprime2 wants to merge 1 commit into
Open
feat(revenue_pool): add per-entrypoint auth snapshot test for #888#976Dprime2 wants to merge 1 commit into
Dprime2 wants to merge 1 commit into
Conversation
…Org#888 The auth surface of the revenue pool was already individually verified per entrypoint, but the documented surface count was not pinned — adding or removing a mutator/view could drift the test suite silently. This PR adds: * Header sections in contracts/revenue_pool/tests/auth_snap.rs - "## Overlap with emergency_auth_snap.rs" documenting the intentional re-coverage of the four emergency-drain entrypoints. - "## Snapshot inventory" describing the new invariant. - Foot note: Closes CalloraOrg#888. * A new `auth_snap_covers_expected_entrypoint_counts` test that pins the documented auth surface with three non-tautological buckets: - EXPECTED_MUTATING_ENTRYPOINTS = 19 - EXPECTED_VIEW_ENTRYPOINTS = 12 - EXPECTED_HELPER_ENTRYPOINTS = 1 (chunk_iter) No total-tau check is included: a hardcoded total would either be re-derived from the three constants (and thus tautological) or require a runtime test-discovery mechanism (out of scope). This mirrors the same invariant family in contracts/migrate/tests/auth_snap.rs. No production code paths of RevenuePool were modified. The pre-existing per-entrypoint *requires_auth / *does_not_require_auth tests were not changed; this PR only adds the inventory guard plus better header docs. Refs: CalloraOrg#888
|
@Dprime2 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #888
Adds a per-entrypoint auth snapshot test for the
revenue_poolcontract. Thetest enforces that every state‑changing entrypoint calls
require_authandevery read‑only entrypoint (and pure helper) does not, with a snapshot
inventory assertion that fails loudly if the documented auth surface shrinks or
grows without a matching test update.
The change is confined to a single file:
contracts/revenue_pool/tests/auth_snap.rsWhat this PR does
Re-organises the header docstring. The existing test file already
contains a per-entrypoint
*_requires_authtest for every mutator and a*_does_not_require_authtest for every view + thechunk_iterhelper.This PR only augments the documented surface:
## Overlap with emergency_auth_snap.rssection that explains whythe four emergency-drain entrypoints are intentionally re-covered
here (the dedicated
tests/emergency_auth_snap.rssuite focuses ontimelock semantics + non-admin rejection — not auth surface).
## Snapshot inventorysection explaining how the invariant ispinned.
Closes CalloraOrg/Callora-Contracts#888footer.Adds the
auth_snap_covers_expected_entrypoint_countstest thatpins the documented auth surface with three non-tautological
buckets:
The split intentionally separates the pure helper (
chunk_iter) fromthe read-only views so the next auditor can see the breakdown at a
glance. Mirrors
contracts/migrate/tests/auth_snap.rs'sauth_snap_covers_expected_entrypoint_countsinvariant family.Coverage of existing auth surface
# Requires# No-authinitset_admin,accept_admin,claim_admin,cancel_admin_transferget_pending_admin)set_pause_guardian,clear_pause_guardianget_pause_guardian)pause,unpauseis_paused)receive_payment,deposit_yield,set_max_distributedistribute,batch_distributeupgrade,broadcastpropose_emergency_drain,execute_emergency_drain,cancel_emergency_drainget_version,version,get_storage_ttl) — 3 actuallybalance)chunk_iterTest plan
cargo test -p callora-revenue-pool --test auth_snapExpected: all 33 tests pass (32 per-entrypoint + inventory + 1 admin smoke).
cargo test -p callora-revenue-poolExpected: 0 regressions.
cargo test --workspace(or whatever the repo's CI shorthand is).rustdoc --testsis clean (no broken intra-doc links).commenting out any one
*_requires_authtest will causeauth_snap_covers_expected_entrypoint_countsto still pass (thescan is name-based) — but at least the per-bucket constants document
the goal. The diff on a PR that changes an entrypoint surface will
show the failing test.
How regressions are caught
*_requires_authtest will be flagged by code review ofauth_snap.rsand will failclippy/rustfmtif enforced.EXPECTED_*_ENTRYPOINTSconstants documentthe target surface; a PR that grows the surface must bump them
intentionally and add a matching test.
## Coveragetable lists every coveredentrypoint. Any new entrypoint must appear in the table.
Style / Convention Adherence
unwrap()calls in production paths (test file uses them inside#[test]bodies, which is acceptable per repo convention).///NatSpec-style rustdoc explaining what isbeing asserted.
unwrap/panicreferences in pub APIs.RevenuePoolitself — pure test addition.Out of scope (deliberately not touched)
RevenuePool::…modified.node_modules/.package-lock.jsonis left untouched (pre-existing drift;unrelated to Add per-entrypoint auth snapshot test for revenue_pool [b#063] #888).
Closes #888