public void PeerConnectorDiscovery_ConnectsTo_NodeInSameNetworkGroup_WithIpRangeFilteringDisabled() { // IpRangeFiltering enabled by default, disabled explicitly. var nodeSettings = new NodeSettings(this.Network, args: new[] { "-IpRangeFiltering=false" }); var connectionManagerSettingsExisting = new ConnectionManagerSettings(nodeSettings); DataFolder peerFolder = CreateDataFolder(this); var peerAddressManager = new PeerAddressManager(DateTimeProvider.Default, peerFolder, this.extendedLoggerFactory, new SelfEndpointTracker(this.extendedLoggerFactory, connectionManagerSettingsExisting)); Mock <INetworkPeerFactory> networkPeerFactoryExisting = new Mock <INetworkPeerFactory>(); Mock <IConnectionManager> connectionManagerExisting = new Mock <IConnectionManager>(); var networkPeerParameters = new NetworkPeerConnectionParameters(); networkPeerParameters.TemplateBehaviors.Add(new ConnectionManagerBehavior(connectionManagerExisting.Object, this.extendedLoggerFactory)); connectionManagerExisting.SetupGet(np => np.Parameters).Returns(networkPeerParameters); connectionManagerExisting.SetupGet(np => np.ConnectedPeers).Returns(new NetworkPeerCollection()); var peerConnector = new PeerConnectorDiscovery(this.asyncProvider, DateTimeProvider.Default, this.extendedLoggerFactory, this.Network, networkPeerFactoryExisting.Object, this.nodeLifetime, nodeSettings, connectionManagerSettingsExisting, peerAddressManager, new SelfEndpointTracker(this.extendedLoggerFactory, connectionManagerSettingsExisting)); peerConnector.Initialize(connectionManagerExisting.Object); //Peer 1. IPAddress originalAddressPeer1 = IPAddress.Parse("::ffff:57.48.183.81"); // ipv4 var endpointPeer1 = new IPEndPoint(originalAddressPeer1, 80); peerAddressManager.AddPeer(endpointPeer1, IPAddress.Loopback); bool connectedToThisPeer = ConnectToPeer(peerAddressManager, networkPeerFactoryExisting, connectionManagerSettingsExisting, peerConnector, endpointPeer1, connectionManagerExisting); Assert.True(connectedToThisPeer); // Peer 2 has different network group to Peer 1. IPAddress addressInDifferentNetworkGroupPeer2 = IPAddress.Parse("99be:f5c5:adc2:525c:f6d7:7b30:5336:5a0f"); // ipv6 var endpointPeer2 = new IPEndPoint(addressInDifferentNetworkGroupPeer2, 80); peerAddressManager.AddPeer(endpointPeer2, IPAddress.Loopback); connectedToThisPeer = ConnectToPeer(peerAddressManager, networkPeerFactoryExisting, connectionManagerSettingsExisting, peerConnector, endpointPeer2, connectionManagerExisting); Assert.True(connectedToThisPeer); // Different network group: connects. // Peer 3 in same network group as Peer 2. IPAddress addressInSameNetworkGroupPeer3 = IPAddress.Parse("99be:f5c5:adc2:525c:db45:d36e:ce01:a394"); // ipv6 var endpointPeer3 = new IPEndPoint(addressInSameNetworkGroupPeer3, 80); peerAddressManager.AddPeer(endpointPeer3, IPAddress.Loopback); connectedToThisPeer = ConnectToPeer(peerAddressManager, networkPeerFactoryExisting, connectionManagerSettingsExisting, peerConnector, endpointPeer3, connectionManagerExisting); Assert.True(connectedToThisPeer); // Same network group: connects. // Peer 4 has different network group to Peer 1. IPAddress addressInDifferentNetworkGroupPeer4 = IPAddress.Parse("::ffff:58.48.183.81"); // ipv4 var endpointPeer4 = new IPEndPoint(addressInDifferentNetworkGroupPeer4, 80); peerAddressManager.AddPeer(endpointPeer4, IPAddress.Loopback); connectedToThisPeer = ConnectToPeer(peerAddressManager, networkPeerFactoryExisting, connectionManagerSettingsExisting, peerConnector, endpointPeer4, connectionManagerExisting); Assert.True(connectedToThisPeer); // Different network group: connects. // Peer 5 has same network group as Peer 1. IPAddress addressInSameNetworkGroupPeer5 = IPAddress.Parse("::ffff:57.48.183.82"); // ipv4 var endpointPeer5 = new IPEndPoint(addressInSameNetworkGroupPeer5, 80); peerAddressManager.AddPeer(endpointPeer5, IPAddress.Loopback); connectedToThisPeer = ConnectToPeer(peerAddressManager, networkPeerFactoryExisting, connectionManagerSettingsExisting, peerConnector, endpointPeer5, connectionManagerExisting); Assert.True(connectedToThisPeer); // Same network group: connects. }