# **Update 15** I've written tests to verify the successful transmission of data through the TLS protocol, as requested by my mentor. The tests ensure that the TLS handshake is performed correctly and that data is securely transmitted between peers. You can check the PR here: [link to PR](https://github.com/NethermindEth/dotnet-libp2p/pull/107). ### Key Components of the Test: 1. **Test Setup**: - **Channels**: `TestChannel` simulates communication between the client and server. - **Mocked Dependencies**: `IChannelFactory`, `IPeerContext`, and `ILoggerFactory` are mocked to handle channel creation, peer identity, and logging. - **Peer Identity & Multiplexer Settings**: Both the initiator and listener are configured with mock peer identities and multiplexer settings. [Code Reference](https://github.com/NethermindEth/dotnet-libp2p/blob/cb15fac3633962da8a856981712ff1c94f021fd8/src/libp2p/Libp2p.Protocols.Tls.Tests/TlsProtocolTests.cs#L14) 2. **TLS Protocol Initialization**: - Two instances of `TlsProtocol` are created, one for the listener and one for the initiator, using the mocked logger and multiplexer settings. [Code Reference](https://github.com/NethermindEth/dotnet-libp2p/blob/cb15fac3633962da8a856981712ff1c94f021fd8/src/libp2p/Libp2p.Protocols.Tls.Tests/TlsProtocolTests.cs#L44) 3. **Execution**: - The listener waits for a connection with `ListenAsync`, and the initiator establishes the connection using `DialAsync`. After the handshake, the listener sends data, and the initiator reads it. [Code Reference](https://github.com/NethermindEth/dotnet-libp2p/blob/cb15fac3633962da8a856981712ff1c94f021fd8/src/libp2p/Libp2p.Protocols.Tls.Tests/TlsProtocolTests.cs#L48) 4. **Assertions**: - The test verifies that the data sent by the listener matches the data received by the initiator, confirming successful TLS-secured transmission. [Code Reference](https://github.com/NethermindEth/dotnet-libp2p/blob/cb15fac3633962da8a856981712ff1c94f021fd8/src/libp2p/Libp2p.Protocols.Tls.Tests/TlsProtocolTests.cs#L61) ### Purpose of the Test: This test validates that the TLS protocol establishes a secure connection and enables successful data transmission between peers. By simulating both the initiator and listener sides, it ensures that the handshake completes correctly and data integrity is maintained. --- **Next Steps**: I plan to enhance the TLS protocol by pre-selecting a muxer, so that negotiation is completed in advance. This can be done using: `serverAuthenticationOptions.ApplicationProtocols = _protocols;` This approach will streamline the handshake process and improve performance by reducing muxer selection overhead.