Testing
This document provides a comprehensive guide to testing the EigenLayer-AVS system.
This document provides a comprehensive guide to testing the EigenLayer-AVS system. It covers the testing utilities, setup procedures, and best practices for ensuring code quality and reliability. This document focuses specifically on the testing infrastructure and methodologies used in the codebase.
Testing Overview#
The EigenLayer-AVS system uses a combination of unit tests and integration tests to verify the functionality of its components. Testing is primarily implemented using Go's built-in testing framework, with additional utilities provided in the testutil package.
Sources:
Testing Utilities#
The testutil
package provides a set of utilities for setting up test environments and creating test data. These utilities help ensure tests are consistent, isolated, and representative of real-world scenarios.
Core Testing Utilities#
Sources:
Key Testing Utilities#
-
Test Database Creation: Creates a temporary BadgerDB instance for testing
-
Test RPC Configuration: Provides URL configuration for connecting to test blockchain nodes
-
Test Users: Pre-configured user objects for testing
-
Test Tasks: Pre-configured task templates for common test scenarios
-
Mock HTTP Servers: Creating test HTTP servers for isolated testing
Sources:
- core/testutil/utils.go85-97
- core/testutil/utils.go28-44
- core/testutil/utils.go107-127
- core/testutil/utils.go189-219
- core/taskengine/executor_test.go23-28
Test Configuration#
The EigenLayer-AVS testing framework provides multiple configuration options to support different testing environments.
Environment Variables#
Environment Variable | Purpose | Default Value |
---|---|---|
RPC_URL | Ethereum RPC endpoint for tests | https://sepolia.drpc.org |
WS_RPC_URL | WebSocket RPC endpoint for tests | wss://sepolia.drpc.org |
CONTROLLER_PRIVATE_KEY | Private key for controller wallet | N/A (Required) |
BASE_SEPOLIA_RPC_URL | Base Sepolia RPC endpoint | N/A |
BASE_SEPOLIA_BUNDLER_RPC | Base Sepolia bundler RPC | N/A |
FACTORY_ADDRESS | Address of account factory contract | 0x29adA1b5217242DEaBB142BC3b1bCfFdd56008e7 |
Sources:
Test Configuration Objects#
The testutil
package provides pre-configured objects for various test scenarios:
-
Aggregator Configuration:
-
Smart Wallet Configuration:
-
Cache Configuration:
Sources:
Unit Testing Approach#
Unit tests in EigenLayer-AVS focus on testing individual components in isolation. The system extensively uses mocks and test doubles to isolate components from their dependencies.
Sources:
Task Executor Testing Example#
The task executor tests demonstrate the unit testing approach by:
- Setting up a test environment with a mock HTTP server
- Creating a test task with specific nodes and edges
- Running the task through the executor
- Verifying execution steps and output data
This approach isolates the executor component while still testing its interactions with other system components through controlled interfaces.
Sources:
Test Case Organization#
Test cases in EigenLayer-AVS are organized to cover various scenarios, including:
Test Category | Purpose | Example |
---|---|---|
Happy Path | Verify correct behavior under normal conditions | TestExecutorRunTaskSucess |
Error Handling | Verify graceful handling of errors | TestExecutorRunTaskStopAndReturnErrorWhenANodeFailed |
Edge Cases | Test behavior at boundary conditions | TestExecutorRunTaskComputeSuccessFalseWhenANodeFailedToRun |
Data Verification | Validate correct data processing | TestExecutorRunTaskReturnAllExecutionData |
Sources:
- core/taskengine/executor_test.go17-129
- core/taskengine/executor_test.go131-217
- core/taskengine/executor_test.go219-311
- core/taskengine/executor_test.go314-556
Test Data Generation#
The system provides utilities for generating different types of test tasks:
Sources:
REST API Test Task#
A predefined REST API task that makes HTTP requests to httpbin.org with a block trigger:
Sources:
Custom JavaScript Test Task#
A predefined JavaScript task that executes simple JavaScript code with a block trigger:
Sources:
Best Practices#
When writing tests for the EigenLayer-AVS system, consider the following best practices:
- Use the provided test utilities: Leverage the testutil package to create consistent test environments
- Clean up test resources: Use defer statements to clean up resources like databases and HTTP servers
- Test both success and failure cases: Ensure your tests cover both normal operation and error handling
- Use isolated test environments: Create separate databases and configurations for each test
- Mock external dependencies: Use httptest.Server to mock HTTP endpoints and other external services
- Verify execution steps: Check both the final result and the intermediate steps of complex operations
- Test with realistic data: Use the provided test data generators or create data that closely mimics production
Sources:
- core/taskengine/executor_test.go17-129
- core/taskengine/executor_test.go131-217
- core/taskengine/executor_test.go219-311
Continuous Integration#
Tests are executed as part of the continuous integration pipeline. For more information about CI/CD and release processes, refer to the CI/CD and Releases documentation.
Feature this wiki to auto refresh weekly