Fixes PeerTableTests of CodexReleaseTests
This commit is contained in:
parent
86d5ab22f6
commit
d7c3fe6c5f
@ -14,7 +14,7 @@ namespace CodexPlugin
|
||||
{
|
||||
string GetName();
|
||||
string GetPeerId();
|
||||
DebugInfo GetDebugInfo();
|
||||
DebugInfo GetDebugInfo(bool log = false);
|
||||
string GetSpr();
|
||||
DebugPeer GetDebugPeer(string peerId);
|
||||
ContentId UploadFile(TrackedFile file);
|
||||
@ -123,11 +123,14 @@ namespace CodexPlugin
|
||||
return peerId;
|
||||
}
|
||||
|
||||
public DebugInfo GetDebugInfo()
|
||||
public DebugInfo GetDebugInfo(bool log = false)
|
||||
{
|
||||
var debugInfo = CodexAccess.GetDebugInfo();
|
||||
var known = string.Join(",", debugInfo.Table.Nodes.Select(n => n.PeerId));
|
||||
Log($"Got DebugInfo with id: {debugInfo.Id}. This node knows: [{known}]");
|
||||
if (log)
|
||||
{
|
||||
var known = string.Join(",", debugInfo.Table.Nodes.Select(n => n.PeerId));
|
||||
Log($"Got DebugInfo with id: {debugInfo.Id}. This node knows: [{known}]");
|
||||
}
|
||||
return debugInfo;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
using CodexPlugin;
|
||||
using CodexTests;
|
||||
using CodexTests.Helpers;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -18,43 +19,13 @@ namespace CodexReleaseTests.NodeTests
|
||||
{
|
||||
var nodes = StartCodex(10);
|
||||
|
||||
var retry = new Retry(
|
||||
description: nameof(PeerTableCompleteness),
|
||||
maxTimeout: TimeSpan.FromMinutes(2),
|
||||
sleepAfterFail: TimeSpan.FromSeconds(5),
|
||||
onFail: f => { }
|
||||
);
|
||||
|
||||
retry.Run(() => AssertAllNodesSeeEachOther(nodes));
|
||||
AssertAllNodesSeeEachOther(nodes.Concat([BootstrapNode!]));
|
||||
}
|
||||
|
||||
private void AssertAllNodesSeeEachOther(ICodexNodeGroup nodes)
|
||||
private void AssertAllNodesSeeEachOther(IEnumerable<ICodexNode> nodes)
|
||||
{
|
||||
foreach (var a in nodes)
|
||||
{
|
||||
AssertHasSeenAllOtherNodes(a, nodes);
|
||||
}
|
||||
}
|
||||
|
||||
private void AssertHasSeenAllOtherNodes(ICodexNode node, ICodexNodeGroup nodes)
|
||||
{
|
||||
var localNode = node.GetDebugInfo().Table.LocalNode;
|
||||
|
||||
foreach (var other in nodes)
|
||||
{
|
||||
var info = other.GetDebugInfo();
|
||||
if (info.Table.LocalNode.PeerId != localNode.PeerId)
|
||||
{
|
||||
AssertContainsPeerId(info, localNode.PeerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AssertContainsPeerId(DebugInfo info, string peerId)
|
||||
{
|
||||
var entry = info.Table.Nodes.SingleOrDefault(n => n.PeerId == peerId);
|
||||
if (entry == null) throw new Exception("Table entry not found.");
|
||||
if (!entry.Seen) throw new Exception("Peer not seen.");
|
||||
var helper = new PeerConnectionTestHelpers(GetTestLog());
|
||||
helper.AssertFullyConnected(nodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user