cs-codex-dist-tests/Tests/CodexTests/PeerDiscoveryTests/LayeredDiscoveryTests.cs

52 lines
1.5 KiB
C#
Raw Normal View History

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