Adds test for routing table checks.
This commit is contained in:
parent
ed56d9edcc
commit
96ff3c38bb
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using Logging;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace DistTestCore.Helpers
|
||||
namespace CodexTests.Helpers
|
||||
{
|
||||
public interface IFullConnectivityImplementation
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
using CodexPlugin;
|
||||
using CodexTests;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Tests.PeerDiscoveryTests
|
||||
namespace CodexTests.PeerDiscoveryTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class LayeredDiscoveryTests : CodexDistTest
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
using CodexContractsPlugin;
|
||||
using CodexTests;
|
||||
using GethPlugin;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Tests.PeerDiscoveryTests
|
||||
namespace CodexTests.PeerDiscoveryTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class PeerDiscoveryTests : AutoBootstrapDistTest
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
using DistTestCore.Helpers;
|
||||
using CodexTests.Helpers;
|
||||
using Logging;
|
||||
|
||||
namespace CodexNetDeployer
|
||||
|
|
Loading…
Reference in New Issue