Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define Test Cases for Engagement Contract #6

Open
29 tasks
mehdi-torabiv opened this issue May 31, 2024 · 0 comments
Open
29 tasks

Define Test Cases for Engagement Contract #6

mehdi-torabiv opened this issue May 31, 2024 · 0 comments

Comments

@mehdi-torabiv
Copy link
Contributor

mehdi-torabiv commented May 31, 2024

Test Cases

Role Management

  • Test Admin Role:

    • Ensure the DEFAULT_ADMIN_ROLE can grant roles.
    • Ensure the DEFAULT_ADMIN_ROLE can revoke roles.
    • Verify that only the DEFAULT_ADMIN_ROLE has the ability to manage roles.
    • Ensure the DEFAULT_ADMIN_ROLE cannot transfer ownership unintentionally.
  • Test Provider Role:

    • Verify that the PROVIDER_ROLE can call the addScores(date, ids, cids) and getScore functions.
    • Ensure that the PROVIDER_ROLE can update IPFS data for community tokens and user scores.
    • Confirm that the PROVIDER_ROLE cannot grant or revoke roles.
    • Verify that the PROVIDER_ROLE cannot be granted or revoked by anyone other than the DEFAULT_ADMIN_ROLE.

Minting Functionality

  • Test Minting Conditions:

    • Ensure that a community member can mint a token if they haven't minted one before.
    • Verify that the token count increases by 1 after each mint.
    • Confirm that tokenBalance[tokenId] is set to +1 after minting.
    • Ensure that minting reverts if a community member tries to mint more than one token per community.
    • Verify that minting reverts if the token ID does not exist.
  • Test Token ID Mapping:

    • Verify that minting reverts if the community member has already minted a token.
    • Confirm that minting reverts if the token ID does not exist or is invalid.

Token Issuance

  • Test Issue Function:
    • Ensure the community manager can issue a new token for the community.
    • Verify that issuing a token updates the token mapping correctly.
    • Confirm that the new token can be minted by community members.
    • Ensure that issuing reverts if the token already exists.

Score Management

  • Test getScore Function:

    • Verify that the getScore function is public and can be called by anyone.
    • Ensure that the function returns the correct scores for a given token ID.
    • Confirm that the function handles non-existent token IDs gracefully.
    • Ensure that the function reverts if the token ID is not found.
    • Ensure that the function reverts if the account balance is 0.
    • Check that the string formatting returned by the function is correct.
  • Test addScores Function:

    • Confirm that only the PROVIDER_ROLE can call the addScores(date, ids, cids) function.
    • Verify that the function updates the CIDs correctly.
    • Ensure that the function can handle multiple token IDs and CIDs.
    • Confirm that CIDs are correctly stored and retrievable from IPFS.

Test Structure

To follow a standard testing process and accommodate upgradable contracts and role changes, we break down the test cases into sub-descriptions (Success and Revert) and start all test cases with Should.

This structure ensures comprehensive test coverage for the upgradable contract and role functionalities, including minting, issuing tokens, and score management.

This was referenced Jun 7, 2024
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

No branches or pull requests

1 participant