Quick Start
Run all workspace tests:Unit Tests
Unit tests are located alongside the code they test throughout the workspace.Running All Unit Tests
Run Tests
--release flag enables optimizations, which is recommended for tests involving cryptographic operations.Running Tests for Specific Packages
Test a specific package:Running Specific Tests
Run tests matching a pattern:Tests run in parallel by default. Use
-- --test-threads=1 to run tests sequentially if you encounter issues.Integration Tests
Integration tests verify interactions between components.Running Integration Tests
End-to-End Tests
E2E tests verify the complete node functionality in a live environment.Prerequisites
Build Node with Fast Runtime
E2E tests require the node built with the This enables faster block times for efficient testing.
fast-runtime feature:Running E2E Tests
In a new terminal:E2E Test Structure
Thee2e/ directory contains:
- Test scenarios for transaction submission
- Data availability verification tests
- RPC endpoint tests
- Chain state validation
Benchmarks
Avail includes several benchmark suites for performance testing.Runtime Benchmarks
Benchmark runtime operations using Criterion:Instruction-Level Benchmarks
Benchmark with IAI for CPU instruction counts:Instruction-level benchmarks require
valgrind to be installed:Kate RPC Benchmarks
For Kate RPC benchmarking, you’ll need Deno installed:Code Quality Checks
Formatting
Check code formatting:Linting with Clippy
Run Clippy linter:Feature Validation
Verify compilation with specific features:Test Coverage
Generate test coverage reports using instrumentation:Coverage instrumentation may slow down test execution.
Continuous Integration
The project uses GitHub Actions for automated testing.CI Test Workflows
Docker-Based Testing
Run tests in a containerized environment:Build Test Container
Run Tests in Container
Common Test Scenarios
Testing a New Feature
Testing a Bug Fix
Troubleshooting
Tests Timing Out
Increase test timeout:Flaky Tests
Run tests multiple times to identify flakiness:Memory Issues
Run tests with fewer parallel threads:E2E Test Failures
Common issues:- Node not running: Ensure the dev node is running with
--devflag - Wrong features: Rebuild node with
--features fast-runtime - Port conflicts: Make sure ports 9944 and 30333 are available
- Stale state: Stop the node, remove the
/tmp/substrate*directory, and restart
Debug Output
Enable detailed logging:Best Practices
Always Use --release
Run tests with
--release flag for realistic performanceTest in Isolation
Use
--test-threads=1 for tests that modify shared stateClean Builds
Periodically clean build artifacts with
cargo cleanCI Parity
Run the same test commands locally as used in CI
Next Steps
Contributing Guidelines
Learn how to contribute your tests and code
Building from Source
Build the node for development and testing