Test Suite Overview
The ENS contracts use Vitest as the test runner with Hardhat for contract compilation and deployment. Tests are written in TypeScript and use viem for blockchain interactions.Running Tests
Basic Test Commands
The following test commands are available in the project:Test Organization
Tests are organized by contract module:- Registry Tests - Core ENS registry functionality
- EthRegistrar Tests - .eth domain registration and renewal
- Resolver Tests - Resolver contract functionality
- Wrapper Tests - NameWrapper contract features
- DNS Tests - DNS integration and DNSSEC
- L2 Tests - Layer 2 deployment tests
Test Environment Setup
Testing on Local Networks
For local testing, you can use Hardhat’s built-in network or Anvil:Using Hardhat Network
Using Anvil
Remote Network Testing
To test against remote networks like testnets:Writing Tests
Tests use Vitest and the ENS Hardhat Chai Matchers for viem:Test Coverage
The test suite covers:- Unit Tests - Individual contract functions
- Integration Tests - Multi-contract interactions
- Deployment Tests - Deployment script validation
- Upgrade Tests - Migration and upgrade scenarios
- Security Tests - Access control and permissions
Continuous Integration
The project uses Travis CI for automated testing. Tests run on every commit and pull request.Best Practices
Use descriptive test names
Use descriptive test names
Name tests clearly to describe what they’re testing:
Test edge cases
Test edge cases
Include tests for boundary conditions and error cases:
Use parallel tests when possible
Use parallel tests when possible
Run independent tests in parallel for faster execution:
Clean up after tests
Clean up after tests
Reset state between tests to avoid conflicts:
Debugging Tests
For debugging failed tests:Related Resources
Deployment Guide
Learn how to deploy contracts
Hardhat Config
View Hardhat configuration