Skip to content

Conversation

@gitshreevatsa
Copy link

This PR introduces comprehensive unit tests for the FunctionsConsumer contract to validate correct deployment, ownership permissions, and request logic. It ensures that critical functionalities are protected from unauthorized access and behave as expected.

🔍 Summary of Changes

  • Deployment Tests:

    • Verifies DON ID and contract ownership on deployment
  • Ownership Tests:

    • Ensures only the owner can:

      • Set a new DON ID
      • Transfer ownership
    • Validates correct behavior on invalid (non-owner) attempts

  • Chainlink Functions Tests:

    • Confirms that only the owner can invoke sendRequest to trigger Chainlink Functions execution
    • Tests that non-owner attempts to call fail gracefully with proper error assertions
  • Improved Error Handling:

    • Enhanced nested error detection to robustly assert expected revert reasons
  • Environment Variable Setup:

    • Loads sensitive values like PRIVATE_KEY, CHAINLINK_ROUTER_ADDRESS, DON_ID, and SUBSCRIPTION_ID from .env
    • Added guard clauses to gracefully skip tests if config is missing

📦 Dev Dependencies

  • dotenv added to support environment variable injection from .env files

🧪 How to Run Tests

cp .env.example .env # fill in values
npx hardhat test test/unit/FunctionsConsumer.spec.js --network baseSepolia

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.

1 participant