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#

  1. Test Database Creation: Creates a temporary BadgerDB instance for testing

  2. Test RPC Configuration: Provides URL configuration for connecting to test blockchain nodes

  3. Test Users: Pre-configured user objects for testing

  4. Test Tasks: Pre-configured task templates for common test scenarios

  5. Mock HTTP Servers: Creating test HTTP servers for isolated testing

Sources:

Test Configuration#

The EigenLayer-AVS testing framework provides multiple configuration options to support different testing environments.

Environment Variables#

Environment VariablePurposeDefault Value
RPC_URLEthereum RPC endpoint for testshttps://sepolia.drpc.org
WS_RPC_URLWebSocket RPC endpoint for testswss://sepolia.drpc.org
CONTROLLER_PRIVATE_KEYPrivate key for controller walletN/A (Required)
BASE_SEPOLIA_RPC_URLBase Sepolia RPC endpointN/A
BASE_SEPOLIA_BUNDLER_RPCBase Sepolia bundler RPCN/A
FACTORY_ADDRESSAddress of account factory contract0x29adA1b5217242DEaBB142BC3b1bCfFdd56008e7

Sources:

Test Configuration Objects#

The testutil package provides pre-configured objects for various test scenarios:

  1. Aggregator Configuration:

  2. Smart Wallet Configuration:

  3. 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:

  1. Setting up a test environment with a mock HTTP server
  2. Creating a test task with specific nodes and edges
  3. Running the task through the executor
  4. 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 CategoryPurposeExample
Happy PathVerify correct behavior under normal conditionsTestExecutorRunTaskSucess
Error HandlingVerify graceful handling of errorsTestExecutorRunTaskStopAndReturnErrorWhenANodeFailed
Edge CasesTest behavior at boundary conditionsTestExecutorRunTaskComputeSuccessFalseWhenANodeFailedToRun
Data VerificationValidate correct data processingTestExecutorRunTaskReturnAllExecutionData

Sources:

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:

  1. Use the provided test utilities: Leverage the testutil package to create consistent test environments
  2. Clean up test resources: Use defer statements to clean up resources like databases and HTTP servers
  3. Test both success and failure cases: Ensure your tests cover both normal operation and error handling
  4. Use isolated test environments: Create separate databases and configurations for each test
  5. Mock external dependencies: Use httptest.Server to mock HTTP endpoints and other external services
  6. Verify execution steps: Check both the final result and the intermediate steps of complex operations
  7. Test with realistic data: Use the provided test data generators or create data that closely mimics production

Sources:

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