Skip to content

Commit

Permalink
Update NoiseProtocolTests.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
rose2221 authored Aug 16, 2024
1 parent 4c09a5e commit 8b45fdc
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions src/libp2p/Libp2p.Protocols.Noise.Tests/NoiseProtocolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,12 @@ public async Task Test_ConnectionEstablished_AfterHandshake()
[Test]
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();
Expand All @@ -54,9 +51,6 @@ public async Task Test_ConnectionEstablished_With_PreSelectedMuxer()
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
Expand All @@ -65,23 +59,15 @@ public async Task Test_ConnectionEstablished_With_PreSelectedMuxer()
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();

}

[Test]
}
[Test]
public async Task Test_ConnectionClosed_ForBrokenHandshake()
{
// IChannel downChannel = new TestChannel();
Expand Down

0 comments on commit 8b45fdc

Please sign in to comment.