End-to-End (E2E) Testing for Blockchain Synchronization¶
This document describes the comprehensive E2E testing suite for the Fukuii Ethereum Classic client, specifically targeting blockchain synchronization functionality.
Overview¶
The E2E test suite validates the complete blockchain synchronization workflow to ensure that Fukuii can successfully synchronize with peers without issues in P2P handshake, block exchange, or storage operations.
Test Suites¶
1. E2ESyncSpec - Regular Synchronization Tests¶
Location: src/it/scala/com/chipprbots/ethereum/sync/E2ESyncSpec.scala
Purpose: Validates regular blockchain synchronization between peers.
Test Categories:
P2P Handshake¶
- Successful connection establishment between two peers
- Multiple peer connections simultaneously
- Handshake timeout recovery
Block Exchange¶
- Block exchange between two peers
- Block exchange with multiple peers
- Incremental block propagation
- Large batch block handling
Storage Integrity¶
- Consistent storage during synchronization
- Blockchain reorganization handling
- Block data integrity verification
- Block persistence across restarts
Error Handling and Recovery¶
- Recovery from peer disconnection
- Handling peers at different block heights
- Partial block download recovery
Bi-directional Synchronization¶
- Mutual block propagation
- Block propagation across peer network
Tags: IntegrationTest, SyncTest, NetworkTest, DatabaseTest, SlowTest
Execution Time: 10-30 minutes (depending on configuration)
2. E2EFastSyncSpec - Fast Sync Tests¶
Location: src/it/scala/com/chipprbots/ethereum/sync/E2EFastSyncSpec.scala
Purpose: Validates fast sync protocol for efficient initial blockchain synchronization.
Test Categories:
Header Synchronization¶
- Blockchain header download without state
- Pivot block selection and validation
State Synchronization¶
- State download at pivot block
- Complex account structure handling
- State validation against state root
Multi-Peer State Download¶
- State synchronization from multiple peers
- Recovery from incomplete state downloads
- Peer disconnection during state download
Chain Integrity¶
- Chain continuity verification
- Total difficulty calculation
- Transition from fast sync to regular sync
Tags: IntegrationTest, SyncTest, StateTest, NetworkTest, DatabaseTest, SlowTest
Execution Time: 15-40 minutes (depending on configuration)
3. E2EHandshakeSpec - P2P Handshake Tests¶
Location: src/it/scala/com/chipprbots/ethereum/network/E2EHandshakeSpec.scala
Purpose: Validates P2P connection establishment and handshake protocol.
Test Categories:
RLPx Connection Establishment¶
- Basic RLPx connection between peers
- Multiple simultaneous connections
- Bidirectional connection attempts
Ethereum Protocol Handshake¶
- Node status exchange
- Protocol version compatibility
- Genesis block hash verification
Fork Block Exchange¶
- Fork block validation during handshake
- Compatible fork configuration handling
Handshake Timeout Handling¶
- Slow handshake response handling
- Failed handshake retry logic
Peer Discovery and Handshake¶
- Handshake with discovered peers
- Connection maintenance after handshake
Handshake with Chain State¶
- Handshake with peers at different heights
- Handshake with peers at genesis
- Total difficulty exchange
Concurrent Handshakes¶
- Multiple concurrent handshake handling
- Handshakes during active sync
Error Recovery¶
- Recovery from handshake failures
- Incompatible parameter handling
Tags: IntegrationTest, NetworkTest, SlowTest
Execution Time: 10-25 minutes (depending on configuration)
Running the Tests¶
Run All E2E Tests¶
Run Specific Test Suite¶
# Run regular sync E2E tests
sbt "IntegrationTest / testOnly *E2ESyncSpec"
# Run fast sync E2E tests
sbt "IntegrationTest / testOnly *E2EFastSyncSpec"
# Run handshake E2E tests
sbt "IntegrationTest / testOnly *E2EHandshakeSpec"
Run Specific Test¶
# Run a specific test by pattern
sbt "IntegrationTest / testOnly *E2ESyncSpec -- -z 'block exchange'"
Run Tests with Tags¶
# Run only NetworkTest tagged tests
sbt "IntegrationTest / testOnly -- -n NetworkTest"
# Run tests excluding SlowTest
sbt "IntegrationTest / testOnly *E2E* -- -l SlowTest"
Test Infrastructure¶
FakePeer Framework¶
The E2E tests utilize the existing FakePeer framework from sync.util package:
- RegularSyncItSpecUtils.FakePeer: For regular sync testing
- FastSyncItSpecUtils.FakePeer: For fast sync testing
Resource Management¶
Tests use Cats Effect Resource for proper lifecycle management:
customTestCaseResourceM(FakePeer.start2FakePeersRes()) { case (peer1, peer2) =>
// Test implementation
}
This ensures: - Proper peer initialization - Cleanup of resources after test - No resource leaks between tests
Test Configuration¶
Tests use: - TestSyncConfig: Test-specific sync configuration - In-memory storage: RocksDB with temporary directories - Isolated actor systems: Separate for each peer - Configurable metrics: Prometheus metrics for monitoring
Success Criteria¶
P2P Handshake¶
- ✅ Successful RLPx connection establishment
- ✅ Protocol version negotiation
- ✅ Node status exchange
- ✅ Fork compatibility validation
Block Exchange¶
- ✅ Correct block propagation between peers
- ✅ Block validation during exchange
- ✅ Handling of large block batches
- ✅ Recovery from partial downloads
Storage Integrity¶
- ✅ Consistent blockchain state across peers
- ✅ Correct total difficulty calculation
- ✅ Valid chain continuity
- ✅ Proper block persistence
Fast Sync¶
- ✅ Correct pivot block selection
- ✅ Complete state download
- ✅ State root validation
- ✅ Smooth transition to regular sync
Known Limitations¶
- Test Duration: Some tests are marked as
SlowTestdue to blockchain operations - Resource Usage: Multiple peers require significant memory (configured in
.jvmopts) - Non-deterministic Timing: Some tests use delays for network operations
Troubleshooting¶
Test Timeout¶
If tests timeout: - Increase timeout in test configuration - Check available system resources - Review logs for stuck operations
Connection Issues¶
If peers fail to connect: - Verify network configuration - Check for port conflicts - Review handshaker logs
Storage Issues¶
If storage tests fail:
- Ensure sufficient disk space in /tmp
- Check RocksDB configuration
- Verify cleanup between tests
Integration with CI/CD¶
GitHub Actions¶
E2E tests are executed in the CI pipeline:
Nightly Builds¶
Comprehensive E2E tests run in nightly builds with extended timeouts.
Metrics and Monitoring¶
Tests collect the following metrics:
- Connection establishment time
- Block download rate
- State download progress
- Handshake success/failure rate
- Storage operation latency
Future Enhancements¶
- Network Simulation: Add network latency and packet loss simulation
- Byzantine Behavior: Test handling of malicious peers
- Large-Scale Testing: Increase peer count for network testing
- Performance Benchmarks: Add performance metrics collection
- Chaos Testing: Random peer failures and recoveries
Contributing¶
When adding new E2E tests:
- Follow existing test structure and patterns
- Use appropriate ScalaTest tags
- Ensure proper resource cleanup
- Document expected behavior
- Consider test execution time
References¶
- Issue: E2E testing for blockchain synchronization
- Test Tagging Guide
- Testing Documentation
- Sync Architecture
Revision History¶
| Date | Version | Changes | Author |
|---|---|---|---|
| 2025-11-16 | 1.0 | Initial E2E test suite implementation | GitHub Copilot |
Maintained by: Chippr Robotics Engineering Team
Last Updated: November 16, 2025