public void PeerConnectorAddNode_PeerAlreadyConnected_Scenario1() { this.CreateTestContext("PeerConnectorAddNode_PeerAlreadyConnected_Scenario1"); var peerConnectorAddNode = new PeerConnectorAddNode(new AsyncLoopFactory(this.loggerFactory), DateTimeProvider.Default, this.loggerFactory, this.network, this.networkPeerFactory, this.nodeLifetime, this.nodeSettings, this.connectionSetting, this.peerAddressManager); var peerDiscovery = new PeerDiscovery(new AsyncLoopFactory(this.loggerFactory), this.loggerFactory, this.network, this.networkPeerFactory, this.nodeLifetime, this.nodeSettings, this.peerAddressManager); var connectionSettings = new ConnectionManagerSettings(); connectionSettings.Load(this.nodeSettings); IConnectionManager connectionManager = new ConnectionManager( DateTimeProvider.Default, this.loggerFactory, this.network, this.networkPeerFactory, this.nodeSettings, this.nodeLifetime, this.parameters, this.peerAddressManager, new IPeerConnector[] { peerConnectorAddNode }, peerDiscovery, connectionSettings); // Create a peer to add to the already connected peers collection. using (NodeBuilder builder = NodeBuilder.Create()) { CoreNode coreNode = builder.CreateStratisPowNode(); builder.StartAll(); using (NetworkPeer networkPeer = coreNode.CreateNetworkPeerClient()) { // Add the network peers to the connection manager's // add node collection. connectionManager.AddNodeAddress(networkPeer.PeerAddress.Endpoint); // Add the peer to the already connected // peer collection of connection manager. // // This is to simulate that a peer has successfully connected // and that the add node connector's Find method then won't // return the added node. connectionManager.AddConnectedPeer(networkPeer); // Re-initialize the add node peer connector so that it // adds the successful address to the address manager. peerConnectorAddNode.Initialize(connectionManager); // TODO: Once we have an interface on NetworkPeer we can test this properly. // The already connected peer should not be returned. //var peer = peerConnectorAddNode.FindPeerToConnectTo(); //Assert.Null(peer); } } }