Skip to content

[TESTING] Add BTT tests for diamond module, inspect & upgrade facets/modules #339

@maxnorm

Description

@maxnorm

Please look through our documentation, discussions and codebase to ensure your issue is well-researched and not already covered.

Testing Issue

Help us improve our test coverage and quality:

Description

Add behavior-driven tests (BTT/fuzz + edge-case behavior checks) for the diamond internal module and related inspect/upgrade facets.
These files implement core selector import/validation, facet linked-list bookkeeping, add/replace/remove upgrade flows, fallback dispatch, and introspection views. They are security-critical and currently appear to have no dedicated tests.

The new tests should validate happy paths, revert paths, list-link integrity, selectorCount/facetCount invariants, and introspection correctness after multi-step upgrades.

Target File/Function(s) being tested

  • src/diamond/DiamondInspectFacet.sol
  • src/diamond/DiamondMod.sol
  • src/diamond/DiamondUpgradeFacet.sol
  • src/diamond/DiamondUpgradeMod.sol

Suggested coverage focus:

  • invalid selector encoding / no bytecode / no selectors reverts
  • duplicate selector conflicts on add
  • replace with same facet, replace non-existent facet, replace with selector ownership conflicts
  • remove non-existent facet
  • head/tail relinking correctness when replacing/removing first, middle, and last facets
  • selectorCount/facetCount invariants across sequences of add→replace→remove
  • delegatecall bubbling + DiamondDelegateCall and DiamondMetadata event behavior
  • introspection consistency (facetAddresses, facets, facetFunctionSelectors) after each upgrade step

We aim the full coverage when possible

Helpful Information

Have a question? Please check our contribution guide first - your answer might already be there!

Want to discuss something? For general questions, ideas, or brainstorming, please browse our discussions or start a new one.

You can also join our Discord to discuss the testing issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions