Skip to content

Commit d7c3fe6

Browse files
committed
Fixes PeerTableTests of CodexReleaseTests
1 parent 86d5ab2 commit d7c3fe6

File tree

2 files changed

+12
-38
lines changed

2 files changed

+12
-38
lines changed

ProjectPlugins/CodexPlugin/CodexNode.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public interface ICodexNode : IHasContainer, IHasMetricsScrapeTarget, IHasEthAdd
1414
{
1515
string GetName();
1616
string GetPeerId();
17-
DebugInfo GetDebugInfo();
17+
DebugInfo GetDebugInfo(bool log = false);
1818
string GetSpr();
1919
DebugPeer GetDebugPeer(string peerId);
2020
ContentId UploadFile(TrackedFile file);
@@ -123,11 +123,14 @@ public string GetPeerId()
123123
return peerId;
124124
}
125125

126-
public DebugInfo GetDebugInfo()
126+
public DebugInfo GetDebugInfo(bool log = false)
127127
{
128128
var debugInfo = CodexAccess.GetDebugInfo();
129-
var known = string.Join(",", debugInfo.Table.Nodes.Select(n => n.PeerId));
130-
Log($"Got DebugInfo with id: {debugInfo.Id}. This node knows: [{known}]");
129+
if (log)
130+
{
131+
var known = string.Join(",", debugInfo.Table.Nodes.Select(n => n.PeerId));
132+
Log($"Got DebugInfo with id: {debugInfo.Id}. This node knows: [{known}]");
133+
}
131134
return debugInfo;
132135
}
133136

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using CodexPlugin;
22
using CodexTests;
3+
using CodexTests.Helpers;
34
using NUnit.Framework;
45
using System;
56
using System.Collections.Generic;
@@ -18,43 +19,13 @@ public void PeerTableCompleteness()
1819
{
1920
var nodes = StartCodex(10);
2021

21-
var retry = new Retry(
22-
description: nameof(PeerTableCompleteness),
23-
maxTimeout: TimeSpan.FromMinutes(2),
24-
sleepAfterFail: TimeSpan.FromSeconds(5),
25-
onFail: f => { }
26-
);
27-
28-
retry.Run(() => AssertAllNodesSeeEachOther(nodes));
29-
}
30-
31-
private void AssertAllNodesSeeEachOther(ICodexNodeGroup nodes)
32-
{
33-
foreach (var a in nodes)
34-
{
35-
AssertHasSeenAllOtherNodes(a, nodes);
36-
}
37-
}
38-
39-
private void AssertHasSeenAllOtherNodes(ICodexNode node, ICodexNodeGroup nodes)
40-
{
41-
var localNode = node.GetDebugInfo().Table.LocalNode;
42-
43-
foreach (var other in nodes)
44-
{
45-
var info = other.GetDebugInfo();
46-
if (info.Table.LocalNode.PeerId != localNode.PeerId)
47-
{
48-
AssertContainsPeerId(info, localNode.PeerId);
49-
}
50-
}
22+
AssertAllNodesSeeEachOther(nodes.Concat([BootstrapNode!]));
5123
}
5224

53-
private void AssertContainsPeerId(DebugInfo info, string peerId)
25+
private void AssertAllNodesSeeEachOther(IEnumerable<ICodexNode> nodes)
5426
{
55-
var entry = info.Table.Nodes.SingleOrDefault(n => n.PeerId == peerId);
56-
if (entry == null) throw new Exception("Table entry not found.");
57-
if (!entry.Seen) throw new Exception("Peer not seen.");
27+
var helper = new PeerConnectionTestHelpers(GetTestLog());
28+
helper.AssertFullyConnected(nodes);
5829
}
5930
}
6031
}

0 commit comments

Comments
 (0)