2023-05-10 07:55:36 +00:00
|
|
|
|
using DistTestCore;
|
2023-05-29 07:13:38 +00:00
|
|
|
|
using DistTestCore.Helpers;
|
2023-05-10 07:55:36 +00:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
|
|
namespace Tests.PeerDiscoveryTests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class LayeredDiscoveryTests : DistTest
|
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void TwoLayersTest()
|
|
|
|
|
{
|
|
|
|
|
var root = SetupCodexNode();
|
|
|
|
|
var l1Source = SetupCodexNode(s => s.WithBootstrapNode(root));
|
|
|
|
|
var l1Node = SetupCodexNode(s => s.WithBootstrapNode(root));
|
|
|
|
|
var l2Target = SetupCodexNode(s => s.WithBootstrapNode(l1Node));
|
|
|
|
|
|
|
|
|
|
AssertAllNodesConnected();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void ThreeLayersTest()
|
|
|
|
|
{
|
|
|
|
|
var root = SetupCodexNode();
|
|
|
|
|
var l1Source = SetupCodexNode(s => s.WithBootstrapNode(root));
|
|
|
|
|
var l1Node = SetupCodexNode(s => s.WithBootstrapNode(root));
|
|
|
|
|
var l2Node = SetupCodexNode(s => s.WithBootstrapNode(l1Node));
|
|
|
|
|
var l3Target = SetupCodexNode(s => s.WithBootstrapNode(l2Node));
|
|
|
|
|
|
|
|
|
|
AssertAllNodesConnected();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestCase(3)]
|
|
|
|
|
[TestCase(5)]
|
|
|
|
|
[TestCase(10)]
|
2023-05-11 10:44:53 +00:00
|
|
|
|
[TestCase(20)]
|
2023-05-10 07:55:36 +00:00
|
|
|
|
public void NodeChainTest(int chainLength)
|
|
|
|
|
{
|
|
|
|
|
var node = SetupCodexNode();
|
|
|
|
|
for (var i = 1; i < chainLength; i++)
|
|
|
|
|
{
|
|
|
|
|
node = SetupCodexNode(s => s.WithBootstrapNode(node));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AssertAllNodesConnected();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AssertAllNodesConnected()
|
|
|
|
|
{
|
2023-05-29 07:13:38 +00:00
|
|
|
|
PeerConnectionTestHelpers.AssertFullyConnected(GetAllOnlineCodexNodes());
|
2023-05-10 07:55:36 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|