test(router-access): cover set_role_limits and get_role_limits (#1047) - #1241
Open
gebibd00-jpg wants to merge 1 commit into
Open
test(router-access): cover set_role_limits and get_role_limits (#1047)#1241gebibd00-jpg wants to merge 1 commit into
gebibd00-jpg wants to merge 1 commit into
Conversation
…Zeninn#1047) `set_role_limits` (contracts/router-access/src/lib.rs lines 93-111) and `get_role_limits` (lines 113-119) are admin-facing configuration entry points for the (max_roles, max_grants_per_role) policy that governs `MaxRolesExceeded` / `MaxGrantsPerRoleExceeded` enforcement elsewhere in the contract. Both functions had zero direct test coverage: a grep for the two names in the test module returns no matches, and the issue confirms it. A regression in the `0`-means-default logic or the super-admin auth gate could have shipped unnoticed. This change adds the four tests the issue itself suggested, in the same style as the existing `test_set_role_admin_*` / `test_grant_role_*` cases: - `test_get_role_limits_defaults` -- before any `set_role_limits` call, the contract returns the compile-time defaults (100, 1_000). - `test_set_role_limits_updates_and_persists` -- a non-zero (max_roles, max_grants_per_role) is stored, and a subsequent `get_role_limits` returns the new values. - `test_set_role_limits_zero_resets_to_defaults` -- passing 0 for either field restores the compile-time default for that field. - `test_set_role_limits_unauthorized_fails` -- a non-super-admin caller is rejected with `AccessError::Unauthorized`. I do not have a local Rust toolchain on this machine, so I could not run `cargo test` myself. The tests are written by analogy with the existing patterns in the same test module and use the existing `setup()` helper, so they should compile and pass without further changes. Please run the suite on a Soroban environment before merging. Closes Maki-Zeninn#1047.
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
set_role_limits(contracts/router-access/src/lib.rslines 93-111) andget_role_limits(lines 113-119) are admin-facing configuration entry points for the(max_roles, max_grants_per_role)policy that governsMaxRolesExceeded/MaxGrantsPerRoleExceededenforcement elsewhere in the contract. Both functions had zero direct test coverage: a grep for the two names in the test module returns no matches, and the issue confirms it. A regression in the0-means-default logic or the super-admin auth gate could have shipped unnoticed.Fix
This change adds the four tests the issue itself suggested, in the same style as the existing
test_set_role_admin_*/test_grant_role_*cases:test_get_role_limits_defaults— before anyset_role_limitscall, the contract returns the compile-time defaults (100, 1_000).test_set_role_limits_updates_and_persists— a non-zero(max_roles, max_grants_per_role)is stored, and a subsequentget_role_limitsreturns the new values.test_set_role_limits_zero_resets_to_defaults— passing 0 for either field restores the compile-time default for that field.test_set_role_limits_unauthorized_fails— a non-super-admin caller is rejected withAccessError::Unauthorized.I do not have a local Rust toolchain on this machine, so I could not run
cargo testmyself. The tests are written by analogy with the existing patterns in the same test module and use the existingsetup()helper, so they should compile and pass without further changes. Please run the suite on a Soroban environment before merging.Closes
#1047