internal async Task <(ConnectionLoop, ConnectionLoop)> ConnectTo(TestNode other) { var pipe = DuplexPipe.CreateConnection(PipeOptions.Default, PipeOptions.Default); var(conn, descriptor) = this.CreateConnection(pipe.Application); var(conn2, descriptor2) = other.CreateConnection(pipe.Transport); // manually start outbound connection from node A. var initialSend = PeerManager.NewOutboundConnection(descriptor, other.NodeConfig.KeysManager.GetNodeSecret().PubKey.ToBytes()); await pipe.Application.Output.WriteAsync(initialSend); var flushResult = pipe.Application.Output.FlushAsync(); if (!flushResult.IsCompleted) { await flushResult.ConfigureAwait(false); } // manually start inbound connection for node B. other.PeerManager.NewInboundConnection(descriptor2); conn.Start(); conn2.Start(); return(conn, conn2); }