# Update 9 This week, I focused on the Nethermind codebase for libp2p and raised a PR as well. I worked on the issue [Optimize muxer selection during handshake](https://github.com/NethermindEth/dotnet-libp2p/issues/18). To enable faster selection, we can pre-select a muxer before the negotiation process, which takes place alongside the handshake. Noise assists with this through its extensions. Link: [PR](https://github.com/NethermindEth/dotnet-libp2p/pull/90) In this PR, I’ve also created test functions to validate the connections. Below are the changes I made to the `NoiseProtocol` file: ``` if (_extensions.StreamMuxers.Any()) { var selectedProtocol = upChannelFactory?.SubProtocols.FirstOrDefault(proto => proto.Id == _extensions.StreamMuxers[0]); context.SpecificProtocolRequest = new ChannelRequest { SubProtocol = selectedProtocol, CompletionSource = context.SpecificProtocolRequest?.CompletionSource }; } ``` The following test function that I added validates the changes in the code: ``` public async Task Test_ConnectionEstablished_With_PreSelectedMuxer() { IChannel downChannel = new TestChannel(); IChannel downChannelFromProtocolPov = ((TestChannel)downChannel).Reverse(); IChannelFactory channelFactory = Substitute.For<IChannelFactory>(); IPeerContext peerContext = Substitute.For<IPeerContext>(); IPeerContext listenerContext = Substitute.For<IPeerContext>(); IProtocol? proto1 = Substitute.For<IProtocol>(); proto1.Id.Returns("proto1"); channelFactory.SubProtocols.Returns(new[] { proto1 }); IChannel upChannel = new TestChannel(); channelFactory.SubDialAndBind(Arg.Any<IChannel>(), Arg.Any<IPeerContext>(), Arg.Any<IProtocol>()) .Returns(Task.FromResult(upChannel)); channelFactory.SubListenAndBind(Arg.Any<IChannel>(), Arg.Any<IPeerContext>(), Arg.Any<IProtocol>()) .Returns(Task.CompletedTask); var multiplexerSettings = new MultiplexerSettings(); multiplexerSettings.Add(proto1); NoiseProtocol proto = new(multiplexerSettings); peerContext.LocalPeer.Identity.Returns(new Identity()); listenerContext.LocalPeer.Identity.Returns(new Identity()); string peerId = peerContext.LocalPeer.Identity.PeerId.ToString(); // Get the PeerId as a string Multiaddress localAddr = $"/ip4/0.0.0.0/tcp/0/p2p/{peerId}"; peerContext.RemotePeer.Address.Returns(localAddr); string listenerPeerId = listenerContext.LocalPeer.Identity.PeerId.ToString(); Multiaddress listenerAddr = $"/ip4/0.0.0.0/tcp/0/p2p/{listenerPeerId}"; listenerContext.RemotePeer.Address.Returns(listenerAddr); Task ListenTask = proto.ListenAsync(downChannel, channelFactory, listenerContext); Task DialTask = proto.DialAsync(downChannelFromProtocolPov, channelFactory, peerContext); await DialTask; await ListenTask; Assert.That(peerContext.SpecificProtocolRequest.SubProtocol, Is.EqualTo(proto1)); await downChannel.CloseAsync(); await upChannel.CloseAsync(); } ```