Skip to content

test: complete role permission matrix and fix spec shaking v2 compat - #184

Merged
El-swaggerito merged 2 commits into
Raegis-RWA:mainfrom
NovusCyber:fix/spec-shaking-and-role-permissions
Jul 30, 2026
Merged

test: complete role permission matrix and fix spec shaking v2 compat#184
El-swaggerito merged 2 commits into
Raegis-RWA:mainfrom
NovusCyber:fix/spec-shaking-and-role-permissions

Conversation

@NovusCyber

Copy link
Copy Markdown
Contributor

Closes #164

Summary

This PR closes the gap on security-critical role permission tests and completely resolves the broken test suite caused by the Soroban SDK's Spec Shaking V2 compiler updates.

Changes Made

1. Role Permission Matrix & State Preservation (Security)

  • State Consistency Assertions: Augmented all wrong-caller tests (where unauthorized operations are blocked) to explicitly verify that the contract state remains unchanged. This includes asserting that balances, total supply, paused state, and whitelist statuses are perfectly preserved upon an Error::Unauthorized rejection.
  • Role Isolation: Verified isolated scopes for Admin, Issuer (AssetManager), Compliance (ComplianceOfficer), and EmergencyOfficer across minting, whitelisting, and pausing operations.
  • Documentation: Role boundaries remain fully documented in docs/admin-roles.md and docs/threat-model.md.

2. Spec Shaking V2 Compatibility Fixes

The Soroban SDK V2 compiler sorts Enum variants alphabetically, which drifted the XDR serialization and caused downstream SDK fixtures to panic.

  • Enum Stabilization: Explicitly defined memory layouts using #[repr(u32)] and Copy traits for AssetStatus, RestrictionReason, CapabilityStatus, and Role. This guarantees deterministic integer indexing on the wire, irrespective of compiler shaking.
  • Fixture Lifecycle Realignment: Fixed test_snapshots/ drift. The contract now properly initializes test states to AssetStatus::Active (since Draft prevents compliance transitions), preventing silent ReceiverNotWhitelisted panics.
  • Event Shape Accuracy: Updated fixture assertions to expect the new canonical compliance_status_changed event emitted prior to the legacy whitelist_revoked/user_whitelisted wrappers.
  • Dead Errors Cleared: Purged obsolete 6000-level error checks (AssetNotActive, AssetLifecyclePaused) from ALL_ERRORS in sdk_fixtures.rs and mapped the fixtures to their active 700x counterparts (AssetPausedRestriction, AssetRetiredRestriction).

Verification

  • cargo test --workspace passes seamlessly without panics.
  • All 168 internal module tests are green.
  • All 9 SDK fixture integrations passed.
  • UPDATE_FIXTURES=1 UPDATE_EXPECT=1 cargo test --workspace executed to fully regenerate and sync XDR JSON snapshots.

Acceptance Criteria Met

  • Role permission test matrix is added.
  • Admin-only operations are tested.
  • Issuer-only operations are tested where applicable.
  • Compliance operations are tested.
  • Wrong-role calls preserve state.
  • Docs explain role assumptions.

Closes: #[Reemplaza con el número de tu Issue, ej: #12]

This commit addresses two critical testing and compilation areas:
1. Spec Shaking V2 Compatibility:
- Added `#[repr(u32)]` to core Enums (AssetStatus, Role, RestrictionReason, CapabilityStatus) to stabilize XDR serialization when Spec Shaking V2 sorts variants alphabetically.
- Adjusted SDK fixtures to accommodate the new canonical `compliance_status_changed` event emitted prior to legacy events.
- Updated obsolete error fixtures (AssetNotActive, AssetLifecyclePaused) to their active Restriction variants (AssetPausedRestriction, AssetRetiredRestriction).
2. Security Role Matrix:
- Verified the complete role matrix covering Admin, AssetManager, ComplianceOfficer, and EmergencyOfficer operations.
- Added explicit state consistency assertions across all wrong-caller tests to guarantee that state (balances, supply, whitelist status, paused state) remains perfectly preserved when an `Error::Unauthorized` rejection occurs.
@El-swaggerito

Copy link
Copy Markdown
Contributor
\nThis PR is currently blocked by merge conflicts.\n\nPlease update the branch with the latest main branch and resolve the conflicts before it can be merged.

…role-permissions

# Conflicts:
#	fixtures/sdk/01-compliance.json
#	fixtures/sdk/05-errors.json
#	src/test.rs
#	tests/sdk_fixtures.rs
@El-swaggerito
El-swaggerito merged commit 0fdabdc into Raegis-RWA:main Jul 30, 2026
1 check passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jul 30, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Aegis role permission tests

2 participants