Skip to content

Add invariant and fuzz tests for MembershipNFT #21

@Lakes41

Description

@Lakes41

Summary

Strengthen smart contract confidence by adding invariant and fuzz tests for membership minting, renewal, suspension, and ownership behaviour.

Current Behaviour

The contract has direct tests for expected flows, but complex sequences and edge cases may not be covered systematically.

Expected Behaviour

The contract test suite should verify important invariants across many generated inputs and state transitions.

Suggested Implementation

Add Foundry fuzz tests and invariant tests around token ownership, wallet-to-token mapping, expiry updates, suspension state, and access control. Include handlers where needed to model realistic sequences of mint, renew, suspend, and transfer attempts.

Files or Areas Likely Affected

  • contracts/src/MembershipNFT.sol
  • contracts/test/MembershipNFT.t.sol
  • contracts/test/
  • contracts/foundry.toml

Acceptance Criteria

  • Fuzz tests cover minting with varied wallets and expiry values
  • Invariants ensure each wallet maps to at most one active membership token
  • Invariants ensure suspended memberships cannot be treated as active
  • Access-controlled functions are tested with authorised and unauthorised callers
  • Edge cases around zero addresses and invalid expiry values are covered
  • Contract tests run successfully through the existing Foundry workflow

Additional Notes

If the contract intentionally permits transfers, invariants should reflect the intended wallet-to-token behaviour after transfer.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

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