Skip to content

Conversation

@adamgall
Copy link
Collaborator

Closes #117

Adds extensive test coverage for the single-step ownership transfer pattern, adapted to work with the current library implementation where access control is enforced by facets, not libraries.

  • test/access/Owner/OwnerFacet.t.sol (19 tests)

    • Immediate ownership transfer functionality
    • Ownership renouncement behavior
    • Access control enforcement
    • Gas optimization benchmarks
    • Documents known renouncement error inconsistency
  • test/access/Owner/LibOwner.t.sol (25 tests)

    • Library internal functions
    • Storage slot verification
    • Event emission testing
    • Fuzz testing for robustness
    • Verifies library doesn't enforce access control (facet's responsibility)
    • Includes TODO comments for 3 tests that will change when renouncement becomes irreversible
  • test/access/Owner/harnesses/OwnerFacetHarness.sol - Exposes internal state for testing

  • test/access/Owner/harnesses/LibOwnerHarness.sol - Exposes library functions

  • ✅ Ownership transfer (immediate effect)

  • ✅ Ownership renouncement (transfer to zero address)

  • ✅ Sequential ownership changes

  • ✅ Access control verification

  • ✅ Event emission

  • ✅ Edge cases (self-transfer, renounced owner behavior)

  • ✅ Storage slot consistency

  • ✅ Gas consumption benchmarks

  • ✅ Fuzz testing with random addresses

Renouncement is currently reversible (to be fixed): The library allows transferOwnership after renouncement. Tests include TODO comments for updating when this is fixed.

…ntrol

Adds extensive test coverage for the single-step ownership transfer pattern, adapted to work with the current library implementation where access control is enforced by facets, not libraries.

- **`test/access/Owner/OwnerFacet.t.sol`** (19 tests)
  - Immediate ownership transfer functionality
  - Ownership renouncement behavior
  - Access control enforcement
  - Gas optimization benchmarks
  - Documents known renouncement error inconsistency

- **`test/access/Owner/LibOwner.t.sol`** (25 tests)
  - Library internal functions
  - Storage slot verification
  - Event emission testing
  - Fuzz testing for robustness
  - Verifies library doesn't enforce access control (facet's responsibility)
  - Includes TODO comments for 3 tests that will change when renouncement becomes irreversible

- `test/access/Owner/harnesses/OwnerFacetHarness.sol` - Exposes internal state for testing
- `test/access/Owner/harnesses/LibOwnerHarness.sol` - Exposes library functions

- ✅ Ownership transfer (immediate effect)
- ✅ Ownership renouncement (transfer to zero address)
- ✅ Sequential ownership changes
- ✅ Access control verification
- ✅ Event emission
- ✅ Edge cases (self-transfer, renounced owner behavior)
- ✅ Storage slot consistency
- ✅ Gas consumption benchmarks
- ✅ Fuzz testing with random addresses

1. **Renouncement is currently reversible** (to be fixed): The library allows `transferOwnership` after renouncement. Tests include TODO comments for updating when this is fixed.

2. **Error inconsistency**: After renouncement, `OwnerFacet` returns a generic `OwnerUnauthorizedAccount` error instead of a specific error. This is preserved for backwards compatibility.

The maintainer has moved to a clean separation of concerns where libraries only handle state management and facets enforce access control. This makes libraries more flexible and composable. Tests verify this architecture by confirming the library doesn't check `msg.sender`.
@github-actions
Copy link

Coverage Report

Coverage

Metric Coverage Details
Lines 34% 231/674 lines
Functions 46% 51/112 functions
Branches 22% 28/129 branches

Last updated: Sun, 26 Oct 2025 06:38:46 GMT for commit 0814080

@mudgen mudgen merged commit 62a1c9e into Perfect-Abstractions:main Oct 26, 2025
1 of 3 checks passed
@mudgen
Copy link
Contributor

mudgen commented Oct 26, 2025

Thanks!

@adamgall
Copy link
Collaborator Author

I haven't yet had the time to diagnose why the test job is failing... @mudgen is it ok to merge with those failures?

@adamgall adamgall deleted the owner-tests branch October 26, 2025 19:48
JackieXu pushed a commit to JackieXu/Compose that referenced this pull request Nov 6, 2025
test: add comprehensive test coverage for Owner single-step access control
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.

[Testing]: Create Comprehensive Test Coverage for Owner Access Control Contracts

2 participants