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

51 lines
1.4 KiB
C#
Raw Normal View History

2024-03-26 09:31:49 +00:00
using NUnit.Framework;
2023-09-12 13:43:30 +00:00
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()
{
2024-05-09 07:32:48 +00:00
var root = StartCodex();
var l1Source = StartCodex(s => s.WithBootstrapNode(root));
var l1Node = StartCodex(s => s.WithBootstrapNode(root));
var l2Target = StartCodex(s => s.WithBootstrapNode(l1Node));
2023-09-12 13:43:30 +00:00
AssertAllNodesConnected();
}
[Test]
public void ThreeLayersTest()
{
2024-05-09 07:32:48 +00:00
var root = StartCodex();
var l1Source = StartCodex(s => s.WithBootstrapNode(root));
var l1Node = StartCodex(s => s.WithBootstrapNode(root));
var l2Node = StartCodex(s => s.WithBootstrapNode(l1Node));
var l3Target = StartCodex(s => s.WithBootstrapNode(l2Node));
2023-09-12 13:43:30 +00:00
AssertAllNodesConnected();
}
[TestCase(3)]
[TestCase(5)]
[TestCase(10)]
public void NodeChainTest(int chainLength)
{
2024-05-09 07:32:48 +00:00
var node = StartCodex();
2023-09-12 13:43:30 +00:00
for (var i = 1; i < chainLength; i++)
{
2024-05-09 07:32:48 +00:00
node = StartCodex(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
}
}
}