Update README.md

This commit is contained in:
AYAHASSAN287 2025-01-28 12:21:00 +02:00 committed by GitHub
parent b166398055
commit 3a6cce2283
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -10,13 +10,66 @@ The primary goal of `testlibs` is to simplify and enhance the testing process fo
- **Peer Management**: Tools for validating peer-to-peer connections, such as connecting, disconnecting, and verifying connected peers.
- **Relay Protocol Testing**: Functions to test relay features like subscribing and unsubscribing to pubsub topics and checking relay peer connections.
- **Utility Functions**: Logging and helper functions to streamline debugging and test execution.
## Key Components
## Key Features
### 1. Wrappers
- **Node Lifecycle Management**: Easily manage the lifecycle of Waku nodes (start, stop, destroy) during tests.
- **Peer Connectivity Testing**: Validate Waku node connections, disconnections, and peer interactions.
- **Relay Subscription Verification**: Test the behavior of the relay protocol and ensure proper topic subscription and peer communication.
- **Seamless Integration**: Built to work with Go's `testing` package and `testify` for straightforward assertions and test setup.
The `wrapper` files define abstractions around the `WakuNode` to streamline node management and interaction during testing. Key functionalities include:
- **Node Lifecycle Management**:
- `Wrappers_StartWakuNode`: Starts a Waku node with a custom or default configuration.
- `Wrappers_Stop`: Stops the Waku node gracefully.
- `Wrappers_Destroy`: Cleans up and destroys the Waku node.
- `Wrappers_StopAndDestroy`: Combines stop and destroy operations for efficient cleanup.
- **Peer Management**:
- `Wrappers_ConnectPeer`: Simplifies connecting nodes by taking a `WakuNode` instance instead of a `peerID`, constructing the `peerID` and connection details internally.
- `Wrappers_DisconnectPeer`: Disconnects a Waku node from a target peer with validation and error handling.
- `Wrappers_GetConnectedPeers`: Retrieves a list of peers connected to the Waku node.
- `Wrappers_GetNumConnectedRelayPeers`: Returns the number of relay peers connected for a specific pubsub topic.
- **Relay Subscription**:
- `Wrappers_RelaySubscribe`: Subscribes the Waku node to a given pubsub topic, ensuring subscription and verifying peer connections.
- `Wrappers_RelayUnsubscribe`: Unsubscribes from a specific pubsub topic and validates the unsubscription process.
---
### 2. Utilities
The `utilities` package provides helper functions and constants to facilitate testing. Key highlights include:
- **Default Configuration**:
- `DefaultWakuConfig`: Provides a baseline Waku node configuration with sensible defaults for testing purposes.
- **Logging Support**:
- Centralized logging via `zap` for debugging during tests.
- Debug-level messages are used extensively to trace the flow and identify issues.
- **Port Management**:
- `GenerateUniquePort`: Dynamically allocates unique ports for Waku nodes during tests to avoid conflicts.
- **Timeout and Error Handling**:
- Constants for peer connection timeouts.
- Enhanced error messaging for debugging failures in Waku node operations.
---
### 3. Test Files
#### Relay Tests (`relay_test.go`)
- **Highlights**:
- Tests the behavior of the relay protocol.
- Example: `TestRelaySubscribeToDefaultTopic` validates subscription to the default pubsub topic and ensures connected relay peers increase.
#### Peer Connection Tests (`Peers_connection_test.go`)
- **Highlights**:
- Simplifies peer connectivity testing using the wrappers.
- Example: `TestConnectMultipleNodesToSingleNode` verifies multiple nodes can connect to a single node efficiently.
#### Basic Node Tests (`Nodes_basic_test.go`)
- **Highlights**:
- Validates fundamental node lifecycle management using wrapper APIs.
- Example: `TestBasicWakuNodes` covers node creation, startup, and cleanup using `Wrappers_StartWakuNode` and `Wrappers_StopAndDestroy`.
## Purpose