Improves retrying in peer test helper

This commit is contained in:
benbierens 2023-05-11 13:59:53 +02:00
parent 38d5b172f4
commit f7e7849460
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
1 changed files with 15 additions and 32 deletions

View File

@ -14,8 +14,6 @@ namespace Tests.PeerDiscoveryTests
}
public static void AssertFullyConnected(BaseLog? log = null, params IOnlineCodexNode[] nodes)
{
Time.Retry(() =>
{
var entries = nodes.Select(n => new Entry(n)).ToArray();
@ -29,7 +27,6 @@ namespace Tests.PeerDiscoveryTests
}
CollectionAssert.IsEmpty(failureMessags);
});
}
private static void AssertKnowEachother(List<string> failureMessags, Entry a, Entry b, BaseLog? log)
@ -44,7 +41,7 @@ namespace Tests.PeerDiscoveryTests
try
{
var response = a.Node.GetDebugPeer(peerId);
var response = GetDebugPeer(a.Node, peerId);
if (string.IsNullOrEmpty(response.peerId) || !response.addresses.Any())
{
failureMessags.Add($"{a.Response.id} did not know peer {peerId}");
@ -54,29 +51,15 @@ namespace Tests.PeerDiscoveryTests
log.Log($"{a.Response.id} knows {peerId}.");
}
}
catch (Exception e)
catch
{
failureMessags.Add($"{a.Response.id} was unable to get 'debug/peer/{peerId}'. {e}");
failureMessags.Add($"{a.Response.id} was unable to get 'debug/peer/{peerId}'.");
}
}
////var enginePeers = string.Join(",", a.enginePeers.Select(p => p.peerId));
////var switchPeers = string.Join(",", a.switchPeers.Select(p => p.peerId));
//var tableNodes = string.Join(",", a.table.nodes.Select(n => n.nodeId));
//var success = a.table.nodes.Any(n => n.nodeId == b.table.localNode.nodeId);
//if (log != null)
//{
// var msg = success ? "PASS" : "FAIL";
// log.Log($"{msg} {a.table.localNode.nodeId} is looking for {b.table.localNode.nodeId} in table-nodes [{tableNodes}]");
//}
////Assert.That(a.enginePeers.Any(p => p.peerId == b.id), $"{a.id} was looking for '{b.id}' in engine-peers [{enginePeers}] but it was not found.");
////Assert.That(a.switchPeers.Any(p => p.peerId == b.id), $"{a.id} was looking for '{b.id}' in switch-peers [{switchPeers}] but it was not found.");
//if (!success)
//{
// failureMessags.Add($"{a.table.localNode.nodeId} was looking for '{b.table.localNode.nodeId}' in table-nodes [{tableNodes}] but it was not found.");
//}
private static CodexDebugPeerResponse GetDebugPeer(IOnlineCodexNode node, string peerId)
{
return Time.Retry(() => node.GetDebugPeer(peerId));
}
public class Entry