Skip to content

Refactor tests to BTT#289

Open
maxnorm wants to merge 22 commits intoPerfect-Abstractions:mainfrom
maxnorm:refactor/access-control-test
Open

Refactor tests to BTT#289
maxnorm wants to merge 22 commits intoPerfect-Abstractions:mainfrom
maxnorm:refactor/access-control-test

Conversation

@maxnorm
Copy link
Collaborator

@maxnorm maxnorm commented Mar 9, 2026

Summary

Refactor tests suite based on the new facet structure and the BTT approach

Changes Made

  • Refactored test suites to BTT: Migrated AccessControl, Owner, ERC20, ERC1155, ERC165, NonReentrancy, ERC721, and Royalty tests to the new facet-based Behavioral Test Tree (BTT) structure.
  • Removed legacy monolithic tests: Deleted old AccessControl/Owner test files and their associated harnesses in favor of the new BTT layout.
  • Added BTT tree specs: Introduced AccessControl.tree, Owner.tree, ERC20.tree, ERC1155.tree, ERC165.tree, NonReentrancy.tree, ERC721.tree, and Royalty.tree behavior-tree specifications to define the new test structure.
  • Introduced new access/owner harness modules: AccessControlCoreMod, AccessControlPausableMod, AccessControlTemporalMod, OwnerCoreMod, and OwnerTwoStepMod harness modules were added, and related harnesses were moved into shared test utilities.
  • Added standardized storage utilities and mocks: AccessControlStorageUtils.sol, OwnerStorageUtils.sol, ERC721StorageUtils.sol, ERC20StorageUtils.sol, and ERC1155StorageUtils.sol were created, explicit getter/setter documentation was added, and related mocks were moved into test utilities for reuse.
  • Expanded AccessControl tests: Coverage for admin, batch grant/revoke, data, grant, pausable, renounce, revoke, and temporal data/grant/revoke behaviors, with both base and facet/mod fuzzing.
  • Expanded Owner/OwnerTwoStep tests: Data, renounce, and transfer behavior coverage for both Owner and OwnerTwoSteps with base and facet/mod fuzzing.
  • Completed ERC20 BTT coverage: Conversion and addition of ERC20 tests to the new BTT pattern were finished.
  • Added ERC1155 BTT tests: Behavior-tree-style tests were introduced for the ERC1155 implementation.
  • Added ERC721 BTT tests: Behavior-tree-style tests for ERC721 (Data, Approve, Transfer, Burn, Enumerable, Metadata) with base and facet fuzzing.
  • Refactored Royalty tests to BTT: Royalty tests (RoyaltyInfo, DefaultRoyalty, TokenRoyalty, Integration, EdgeCases) were migrated to the BTT pattern with facet/mod bases and fuzzing.
  • Refactored ERC165 tests and storage: ERC165 tests and harnesses were updated (now in utils), and the ERC165 storage slot was changed to keccak256("erc165") from keccak256("compose.erc165").
  • Split and extended export selector tests: Export selector checks live in per-area exportSelectors test files, and an explicit ERC165 export selector test was added.
  • Refactored NonReentrancy tests: NonReentrancy tests were updated to align with the new BTT-style structure and shared harness/util patterns.

Checklist

Before submitting this PR, please ensure:

  • Code follows the Solidity feature ban - No inheritance, constructors, modifiers, public/private variables, external library functions, using for directives, or selfdestruct

  • Code follows Design Principles - Readable, uses diamond storage, favors composition over inheritance

  • Code matches the codebase style - Consistent formatting, documentation, and patterns (e.g. ERC20Facet.sol)

  • Code is formatted with forge fmt

  • Existing tests pass - Run tests to be sure existing tests pass.

  • New tests are optional - If you don't provide tests for new functionality or changes then please create a new issue so this can be assigned to someone.

  • All tests pass - Run forge test and ensure everything works

  • Documentation updated - If applicable, update relevant documentation

Make sure to follow the contributing guidelines.

Additional Notes

Special thank you to @lumoswiz for the BTT proposition and initial work on the refactor.

Reference:
#248
#266
#276

@netlify
Copy link

netlify bot commented Mar 9, 2026

👷 Deploy request for compose-diamonds pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit 7772252

@maxnorm maxnorm changed the title Refactor Access tests to BTT Refactor tests to BTT Mar 9, 2026
@github-actions
Copy link

github-actions bot commented Mar 10, 2026

Coverage Report

Coverage

Metric Coverage Details
Lines 78% 1428/1824 lines
Functions 92% 401/437 functions
Branches 73% 156/213 branches

Last updated: Tue, 10 Mar 2026 23:53:05 GMT for commit 7772252

@github-actions
Copy link

github-actions bot commented Mar 10, 2026

Gas Report

No gas usage changes detected between main and refactor/access-control-test.

All functions maintain the same gas costs. ✅

Last updated: Tue, 10 Mar 2026 23:53:05 GMT for commit 7772252

@maxnorm maxnorm requested a review from lumoswiz March 10, 2026 03:30
@maxnorm maxnorm marked this pull request as ready for review March 10, 2026 22:58
@maxnorm maxnorm linked an issue Mar 11, 2026 that may be closed by this pull request
5 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.

Adopt BTT and shared base contract across test suite

1 participant