diff --git a/Tests/CodexContinuousTests/Tests/PeersTest.cs b/Tests/CodexContinuousTests/Tests/PeersTest.cs index 8d5d08b..38d2f4f 100644 --- a/Tests/CodexContinuousTests/Tests/PeersTest.cs +++ b/Tests/CodexContinuousTests/Tests/PeersTest.cs @@ -1,8 +1,9 @@ using CodexPlugin; -using DistTestCore.Helpers; +using CodexTests.Helpers; +using ContinuousTests; using NUnit.Framework; -namespace ContinuousTests.Tests +namespace CodexContinuousTests.Tests { public class PeersTest : ContinuousTest { diff --git a/Tests/CodexTests/CodexDistTest.cs b/Tests/CodexTests/CodexDistTest.cs index d651c65..4d6dab2 100644 --- a/Tests/CodexTests/CodexDistTest.cs +++ b/Tests/CodexTests/CodexDistTest.cs @@ -1,11 +1,11 @@ using CodexContractsPlugin; using CodexNetDeployer; using CodexPlugin; +using CodexTests.Helpers; using Core; using DistTestCore; using DistTestCore.Helpers; using DistTestCore.Logs; -using GethPlugin; using NUnit.Framework; using NUnit.Framework.Constraints; diff --git a/Tests/CodexTests/DownloadConnectivityTests/FullyConnectedDownloadTests.cs b/Tests/CodexTests/DownloadConnectivityTests/FullyConnectedDownloadTests.cs index 2f0a445..0acd780 100644 --- a/Tests/CodexTests/DownloadConnectivityTests/FullyConnectedDownloadTests.cs +++ b/Tests/CodexTests/DownloadConnectivityTests/FullyConnectedDownloadTests.cs @@ -1,10 +1,9 @@ using CodexContractsPlugin; -using CodexTests; using GethPlugin; using NUnit.Framework; using Utils; -namespace Tests.DownloadConnectivityTests +namespace CodexTests.DownloadConnectivityTests { [TestFixture] public class FullyConnectedDownloadTests : AutoBootstrapDistTest diff --git a/Tests/CodexTests/Helpers/FullConnectivityHelper.cs b/Tests/CodexTests/Helpers/FullConnectivityHelper.cs index e0ef335..1504c78 100644 --- a/Tests/CodexTests/Helpers/FullConnectivityHelper.cs +++ b/Tests/CodexTests/Helpers/FullConnectivityHelper.cs @@ -2,7 +2,7 @@ using Logging; using NUnit.Framework; -namespace DistTestCore.Helpers +namespace CodexTests.Helpers { public interface IFullConnectivityImplementation { diff --git a/Tests/CodexTests/Helpers/PeerConnectionTestHelpers.cs b/Tests/CodexTests/Helpers/PeerConnectionTestHelpers.cs index 5d42832..d644296 100644 --- a/Tests/CodexTests/Helpers/PeerConnectionTestHelpers.cs +++ b/Tests/CodexTests/Helpers/PeerConnectionTestHelpers.cs @@ -1,8 +1,8 @@ using CodexPlugin; using Logging; -using static DistTestCore.Helpers.FullConnectivityHelper; +using static CodexTests.Helpers.FullConnectivityHelper; -namespace DistTestCore.Helpers +namespace CodexTests.Helpers { public class PeerConnectionTestHelpers : IFullConnectivityImplementation { diff --git a/Tests/CodexTests/Helpers/PeerDownloadTestHelpers.cs b/Tests/CodexTests/Helpers/PeerDownloadTestHelpers.cs index 6ad178f..fab2a23 100644 --- a/Tests/CodexTests/Helpers/PeerDownloadTestHelpers.cs +++ b/Tests/CodexTests/Helpers/PeerDownloadTestHelpers.cs @@ -2,9 +2,9 @@ using FileUtils; using Logging; using Utils; -using static DistTestCore.Helpers.FullConnectivityHelper; +using static CodexTests.Helpers.FullConnectivityHelper; -namespace DistTestCore.Helpers +namespace CodexTests.Helpers { public class PeerDownloadTestHelpers : IFullConnectivityImplementation { diff --git a/Tests/CodexTests/PeerDiscoveryTests/LayeredDiscoveryTests.cs b/Tests/CodexTests/PeerDiscoveryTests/LayeredDiscoveryTests.cs index 310b6aa..4c8a3b3 100644 --- a/Tests/CodexTests/PeerDiscoveryTests/LayeredDiscoveryTests.cs +++ b/Tests/CodexTests/PeerDiscoveryTests/LayeredDiscoveryTests.cs @@ -1,8 +1,7 @@ using CodexPlugin; -using CodexTests; using NUnit.Framework; -namespace Tests.PeerDiscoveryTests +namespace CodexTests.PeerDiscoveryTests { [TestFixture] public class LayeredDiscoveryTests : CodexDistTest diff --git a/Tests/CodexTests/PeerDiscoveryTests/PeerDiscoveryTests.cs b/Tests/CodexTests/PeerDiscoveryTests/PeerDiscoveryTests.cs index 9eca0c6..57f27a3 100644 --- a/Tests/CodexTests/PeerDiscoveryTests/PeerDiscoveryTests.cs +++ b/Tests/CodexTests/PeerDiscoveryTests/PeerDiscoveryTests.cs @@ -1,9 +1,8 @@ using CodexContractsPlugin; -using CodexTests; using GethPlugin; using NUnit.Framework; -namespace Tests.PeerDiscoveryTests +namespace CodexTests.PeerDiscoveryTests { [TestFixture] public class PeerDiscoveryTests : AutoBootstrapDistTest diff --git a/Tests/CodexTests/PeerDiscoveryTests/RoutingTableTests.cs b/Tests/CodexTests/PeerDiscoveryTests/RoutingTableTests.cs new file mode 100644 index 0000000..8f753ae --- /dev/null +++ b/Tests/CodexTests/PeerDiscoveryTests/RoutingTableTests.cs @@ -0,0 +1,47 @@ +using CodexPlugin; +using NUnit.Framework; + +namespace CodexTests.PeerDiscoveryTests +{ + [TestFixture] + public class RoutingTableTests : AutoBootstrapDistTest + { + [TestCase(2)] + [TestCase(3)] + [TestCase(10)] + [TestCase(20)] + public void VariableNodes(int number) + { + AddCodex(number); + + AssertRoutingTable(); + } + + private void AssertRoutingTable() + { + var all = GetAllOnlineCodexNodes(); + var allNodeIds = all.Select(n => n.GetDebugInfo().table.localNode.nodeId).ToArray(); + + var errors = all.Select(n => AreAllPresent(n, allNodeIds)).Where(s => !string.IsNullOrEmpty(s)).ToArray(); + + if (errors.Any()) + { + Assert.Fail(string.Join(Environment.NewLine, errors)); + } + } + + private string AreAllPresent(ICodexNode n, string[] allNodesIds) + { + var info = n.GetDebugInfo(); + var knownIds = info.table.nodes.Select(n => n.nodeId).ToArray(); + var expectedIds = allNodesIds.Where(id => id != info.table.localNode.nodeId).ToArray(); + + if (!expectedIds.All(ex => knownIds.Contains(ex))) + { + return $"Not all of '{string.Join(",", expectedIds)}' were present in routing table: '{string.Join(",", knownIds)}'"; + } + + return string.Empty; + } + } +} diff --git a/Tools/CodexNetDeployer/PeerConnectivityChecker.cs b/Tools/CodexNetDeployer/PeerConnectivityChecker.cs index 87bdc31..06cb1a5 100644 --- a/Tools/CodexNetDeployer/PeerConnectivityChecker.cs +++ b/Tools/CodexNetDeployer/PeerConnectivityChecker.cs @@ -1,4 +1,4 @@ -using DistTestCore.Helpers; +using CodexTests.Helpers; using Logging; namespace CodexNetDeployer