2
0
mirror of synced 2025-01-23 14:59:14 +00:00

52 lines
1.5 KiB
C#
Raw Normal View History

2023-09-12 15:43:30 +02:00
using CodexPlugin;
using NUnit.Framework;
2023-11-12 10:36:48 +01:00
namespace CodexTests.PeerDiscoveryTests
2023-09-12 15:43:30 +02:00
{
[TestFixture]
2023-09-13 14:24:43 +02:00
public class LayeredDiscoveryTests : CodexDistTest
2023-09-12 15:43:30 +02:00
{
[Test]
public void TwoLayersTest()
{
2023-09-20 12:02:32 +02:00
var root = Ci.StartCodexNode();
var l1Source = Ci.StartCodexNode(s => s.WithBootstrapNode(root));
var l1Node = Ci.StartCodexNode(s => s.WithBootstrapNode(root));
var l2Target = Ci.StartCodexNode(s => s.WithBootstrapNode(l1Node));
2023-09-12 15:43:30 +02:00
AssertAllNodesConnected();
}
[Test]
public void ThreeLayersTest()
{
2023-09-20 12:02:32 +02:00
var root = Ci.StartCodexNode();
var l1Source = Ci.StartCodexNode(s => s.WithBootstrapNode(root));
var l1Node = Ci.StartCodexNode(s => s.WithBootstrapNode(root));
var l2Node = Ci.StartCodexNode(s => s.WithBootstrapNode(l1Node));
var l3Target = Ci.StartCodexNode(s => s.WithBootstrapNode(l2Node));
2023-09-12 15:43:30 +02:00
AssertAllNodesConnected();
}
[TestCase(3)]
[TestCase(5)]
[TestCase(10)]
public void NodeChainTest(int chainLength)
{
2023-09-20 12:02:32 +02:00
var node = Ci.StartCodexNode();
2023-09-12 15:43:30 +02:00
for (var i = 1; i < chainLength; i++)
{
2023-09-20 12:02:32 +02:00
node = Ci.StartCodexNode(s => s.WithBootstrapNode(node));
2023-09-12 15:43:30 +02:00
}
AssertAllNodesConnected();
}
private void AssertAllNodesConnected()
{
2023-09-13 14:24:43 +02:00
CreatePeerConnectionTestHelpers().AssertFullyConnected(GetAllOnlineCodexNodes());
2023-09-12 15:43:30 +02:00
}
}
}