Skip to content

Conversation

@thep2p
Copy link
Owner

@thep2p thep2p commented Aug 9, 2025

No description provided.

thep2p added 30 commits July 17, 2025 11:25
Adds a network module defining the interfaces and structures
for network communication. This includes message types, a
message struct, a message processor trait, and a network trait
with methods for sending messages, registering processors, and
starting/stopping the network service.
Introduces a mock network implementation for testing purposes.

This implementation includes:
- A `NetworkHub` for managing multiple mock networks.
- A `MockNetwork` that simulates network behavior.

The `Identifier` struct is also updated to implement the `Hash` trait.
Updates `new_mock_network` to pass a reference to the `NetworkHub` to the newly created `MockNetwork`.

This allows the `MockNetwork` to interact with the hub, facilitating message routing and network management.
Introduces a test module for the mock network implementation.

Simplifies the network hub by removing the boxed trait object, improving type safety and reducing complexity.
This change also prepares the mock network for more comprehensive testing.
Uses `Rc` instead of `Arc` for mock network management in the hub.

This change improves performance by reducing the overhead associated with heavy locking mechanisms, especially in single-threaded testing scenarios or when mutable access is infrequent.
Updates the mock network implementation to use `Rc`
instead of `Arc` for managing shared mutable state.
This change improves performance by avoiding unnecessary
thread synchronization in the single-threaded mock environment.
Also adds a test suite to test the mock network implementation.
Enables the mock network to simulate receiving and processing messages.

This is achieved by adding an `incoming_message` function that allows injecting messages into the registered message processor.
A test case is added to ensure that the message is properly processed.
Renames the `send_message` function to `incoming_message` for better clarity and to reflect the direction of the message flow.

Also improves error handling by using a wildcard pattern for the lock error.
Removes an unnecessary message variable in the test function to improve code readability and maintainability.
Removes the `get_network` function from the `NetworkHub`, as it is no longer being used.

Also removes the `start` and `stop` functions from both the `Network` trait and the `MockNetwork` implementation, as these functions are no-ops for the mock network and not needed in the trait.
Removes the generic `payload` field from the `Message` struct.
The payload will be handled in a different, more type-safe manner
to avoid the complexities and potential runtime errors associated
with `Any`.
Renames the `MessageType` enum to `Payload` to better reflect its purpose, which is to define the structure of the message payload rather than the message type itself.
This change provides a more accurate and descriptive name for the enum.
Refactors mock network tests for clarity and correctness.

- Simplifies message processor logic for better handling of incoming messages.
- Ensures messages are correctly routed and processed within the mock network, including verification of message processing.
- Updates test assertions to accurately reflect message handling behavior.
Refactors the project structure to enable testing
of the network module.

The network module and its submodules are now only
compiled during testing.
This ensures that the network functionality, mainly
used for testing, does not get included in production.
Adds documentation to the mock network hub and network components
to improve understanding and maintainability.

The documentation describes the purpose and usage of the `NetworkHub` and `MockNetwork` structures and their methods.
Adds a test case to verify concurrent message sending between mock networks.

This test spawns multiple threads that concurrently send messages
to a single recipient to ensure that messages are delivered correctly
in a multithreaded environment. It validates that no messages are lost
during concurrent sending.
Updates the mock network implementation to use `Arc>` instead of `Rc>` for thread safety.
This change allows concurrent access and modification of the mock network state, preventing data races and ensuring safe concurrent testing.
Updates the `MessageProcessor` trait bound in `MockNetwork` to allow for more flexible implementations.

Adds a print statement to confirm message processing in a test.
Adds the skip-graphs paper as a PDF document.
This provides a reference document for the skip-graphs algorithm.
Adds the `Debug` derive macro to the `IdentifierSearchRequest` struct.
This will allow for easier debugging and logging of search requests.
thep2p added 11 commits August 9, 2025 10:27
Implements integration tests for the skip graph functionality.

This commit introduces a new test suite to verify the correct behavior of the skip graph, including:
- Basic skip graph creation and connectivity
- Node search functionality (sequential and concurrent)
- Lookup table validity
- Scalability tests with a larger number of nodes
- Edge case handling
- Performance benchmark test

These tests ensure the skip graph functions as expected and maintains its integrity under various conditions.
Updates assertion messages in integration tests for better readability and debugging. Replaces string formatting with more concise and readable expressions.

Adds linting instructions to AGENTS.md to promote code quality and consistency.
@thep2p thep2p force-pushed the thep2p/local-skip-graph branch from bee7705 to 900ec06 Compare August 13, 2025 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants